Learning How to Register CSS and JS¶
Other CMSs This is a common need in any CMS, so if you're coming from another platform, here are some of the related functions. - WordPress – uses its wp_enqueue_script, wp_register_script, wp_enqueue_style, wp_register_style functions.
Adding to the HEAD¶
This function lets you register any CSS file to the HEAD of the content by providing the URL in the method:
Or, more correctly, you would use the MODX_ASSETS_URL constant so your Snippet or plugin would work even on a site that was configured to use a non-standard assets location.
This function is useful if you need to set some JS variables, or output some HTML into the HEAD:
Adding Before the BODY End¶
Similar to regClientStartupScript except that it runs before the closing BODY tag:
Similar to regClientStartupHTMLBlock except that it runs before the closing BODY tag: