Add CSS or JS to end of all

Permalink
Hi

I want to add CSS and JS to my block in package. But when I add in on_before_render this code:

$this->addFooterItem(Loader::helper('html')->js('smth.js', 'PACKAGE_NAME'));


this JS will be added as first (before f.e. jQuery). But I want to add my JS as last (to use jQuery).

How can I do this ?

IceManSpy
 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi IceManSpy,

If your block needs jQuery to work, you should be requiring it from concrete5. This will deal with situations where a theme might not be providing or requiring it. When jQuery is loaded by concrete5, I believe it is put into the page <head>.

Documentation on requiring assets.
https://www.concrete5.org/documentation/developers/5.7/assets/requir...

For CSS and JS block assets, you should be registering them. By default, I believe registered CSS files are put in the page <head> and JavaScript files are put at the end of the body. You can control where the assets are placed and if they are to be combined and/or minified.

Documentation for registering assets:
https://www.concrete5.org/documentation/developers/5.7/assets/regist...