When using Web Assets basic method like this:
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->registerScript('bar', 'com_example/bar.js', [], ['defer' => true], ['core']);
// And use it later
$wa->useScript('bar');
I noticed that I couldn't really control the position of js scripts (or css files) in the listing deployed in head when displaying page.
Sometimes, it could be necessary, eg when I want my css file to load AFTER template.min.css
With HTMLHelper
, js scripts and css files are (almost) always positioned by the end of the listing, as I wish.
HTMLHelper::_('script', ...
or
HTMLHelper::_('stylesheet',...
Do I miss something somewhere ?
Other question, related:
Is it mandatory to create a joomla.asset.json file in media/myfiles when I just want to add some js or css to an existing extension?
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
Labels |
Added:
Information Required
|
I think you need to declare the dependencies
No. Not if you registerScript in your code. If you do then you can just usescript