Magento – How to load a specific JS at the end of all other included JS files

layouttheme

I have a specific fancybox.js file which I want to load at the end of all the JS files included in my local.xml

If load order can be changed then how can a JS file be loaded (included) at the end ?

Thanks.

Best Answer

You can sort the order of skin or js files in layout.xml by using the params element with a name attribute like this answer explains:-

<action method="addJs"><!-- this will be shown second -->
    <script>prototype/javascript1.js</script>
    <params><![CDATA[name="js002_second"]]></params>
</action>
<action method="addJs"><!-- this will be shown first -->
    <script>prototype/javascript2.js</script>
    <params><![CDATA[name="js001_first"]]></params>
</action>