Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling external js and css in Magento
    text
    copied!<p>I am try to move all my static content to a CDN to improve performance on my Magento store. I can successfully get the script tag I want in the head of the page but I can't figure out how to put it in the right place.</p> <p>The code below outputs the prototype.js script tag below the rest of the output so it does not work. Basically, I just want to know the best way to control the order of the script elements.</p> <p>This is in my page.xml layout file in my theme directory.</p> <pre><code>&lt;block type="page/html_head" name="head" as="head"&gt; &lt;block type="core/text" name="cdn_prototype"&gt; &lt;action method="setText"&gt; &lt;text&gt;&lt;![CDATA[&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js"&gt;&lt;/script&gt;]]&gt;&lt;/text&gt; &lt;/action&gt; &lt;/block&gt; &lt;action method="addJs" ifconfig="dev/js/deprecation"&gt;&lt;script&gt;prototype/deprecation.js&lt;/script&gt;&lt;/action&gt; &lt;action method="addJs"&gt;&lt;script&gt;lib/ccard.js&lt;/script&gt;&lt;/action&gt; &lt;action method="addJs"&gt;&lt;script&gt;prototype/validation.js&lt;/script&gt;&lt;/action&gt; &lt;action method="addJs"&gt;&lt;script&gt;scriptaculous/builder.js&lt;/script&gt;&lt;/action&gt; &lt;action method="addJs"&gt;&lt;script&gt;scriptaculous/effects.js&lt;/script&gt;&lt;/action&gt; &lt;action method="addJs"&gt;&lt;script&gt;scriptaculous/dragdrop.js&lt;/script&gt;&lt;/action&gt; &lt;action method="addJs"&gt;&lt;script&gt;scriptaculous/controls.js&lt;/script&gt;&lt;/action&gt; &lt;action method="addJs"&gt;&lt;script&gt;scriptaculous/slider.js&lt;/script&gt;&lt;/action&gt; &lt;action method="addJs"&gt;&lt;script&gt;varien/js.js&lt;/script&gt;&lt;/action&gt; &lt;action method="addJs"&gt;&lt;script&gt;varien/form.js&lt;/script&gt;&lt;/action&gt; &lt;action method="addJs"&gt;&lt;script&gt;mage/translate.js&lt;/script&gt;&lt;/action&gt; &lt;action method="addJs"&gt;&lt;script&gt;mage/cookies.js&lt;/script&gt;&lt;/action&gt; &lt;action method="addJs"&gt;&lt;script&gt;dvm/menu.js&lt;/script&gt;&lt;/action&gt; &lt;block type="page/js_cookie" name="js_cookies" template="page/js/cookie.phtml"/&gt; &lt;action method="addItem"&gt;&lt;type&gt;skin_js&lt;/type&gt;&lt;name&gt;js/scripts.js&lt;/name&gt;&lt;/action&gt; &lt;action method="addCss"&gt;&lt;stylesheet&gt;css/styles.css&lt;/stylesheet&gt;&lt;/action&gt; &lt;action method="addItem"&gt;&lt;type&gt;skin_css&lt;/type&gt;&lt;name&gt;css/styles-ie.css&lt;/name&gt;&lt;params/&gt;&lt;if&gt;lt IE 8&lt;/if&gt;&lt;/action&gt; &lt;action method="addItem"&gt;&lt;type&gt;skin_css&lt;/type&gt;&lt;name&gt;css/styles-ie-8.css&lt;/name&gt;&lt;params/&gt;&lt;if&gt;lt IE 9&lt;/if&gt;&lt;/action&gt; &lt;action method="addCss"&gt;&lt;stylesheet&gt;css/widgets.css&lt;/stylesheet&gt;&lt;/action&gt; &lt;action method="addCss"&gt;&lt;stylesheet&gt;css/print.css&lt;/stylesheet&gt;&lt;params&gt;media="print"&lt;/params&gt;&lt;/action&gt; &lt;action method="addItem"&gt;&lt;type&gt;js&lt;/type&gt;&lt;name&gt;lib/ds-sleight.js&lt;/name&gt;&lt;params/&gt;&lt;if&gt;lt IE 7&lt;/if&gt;&lt;/action&gt; &lt;action method="addItem"&gt;&lt;type&gt;skin_js&lt;/type&gt;&lt;name&gt;js/iehover-fix.js&lt;/name&gt;&lt;params/&gt;&lt;if&gt;lt IE 7&lt;/if&gt;&lt;/action&gt; &lt;/block&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload