Sunday, 17 August 2014

Controlling order of blocks in Magento layout.xml - jQuery CDN appearing after added skinjs



Having some trouble rendering jQuery in my Magento theme via local.xml in an appropriate position.


Currently, my the section in question in my layout.xml looks like so:



<!-- load jQuery from CDN with local fallback, latest version 1.11.0 -->
<block type="core/text" name="google.cdn.jquery">
<action method="setText">
<text><![CDATA[<script src="//code.jquery.com/jquery-1.11.0.min.js"></script><script>window.jQuery||document.write('<script src="js/jquery-1.11.0.min.js">\x3c/script>');</script><script>jQuery.noConflict();</script>]]></text>
</action>
</block>

<!-- add global JS functions library -->
<action method="addItem"><type>skin_js</type><name>min/global-min.js</name></action>


However the global-min.js file here is rendered before jQuery, which (along with other added core/text type blocks) is sitting after the rest of my skin JS files.


Is there a way to move the CDN loaded jQuery file up in terms of output priority inside the head of my site?


Thanks very much for your help.


No comments:

Post a Comment