Control order of loaded scripts

by antimatter   Last Updated January 11, 2018 17:10 PM

Unfortunatelly I can't register on the joomla forum, so I'll try my best here.
Please help, is there any way to control the order of loaded scripts.

Example: in my template's index.php I do:


as the very first addScript(); So I load that script globally for all pages.

Then, in the default.php of my custom component I do:


to add additional behaviour for that very component view specifically.

Logically I would assume that the addScripts in the index.php are added to the $doc object first and after that the addScripts in the component view are appended $doc object.
But what I end up with in the head is:

<script src="my/script_b.js"></script>
<script src="my/script_a.js"></script>

This bugs me pretty hard since my/script_a.js performes calculations my/script_b.js depends on, so the order is crucial.

Please, there must be a way to control the order of loading scripts otherwise this feature is pretty much pointless, isn't it?

Related Questions

Load javascript script before </body> closing tag

Updated August 05, 2015 13:04 PM

addScript breaking frontend editing

Updated September 22, 2017 20:10 PM

How to set html5 property within template.php

Updated April 04, 2015 17:04 PM