Magento

Add an External JS in Magento

To Add an External JS without any problem use this in XML Layout:

[box type=”info”]<reference name="head"><block type="core/text" name="google.cdn.jquery">
<action method="setText"><text><![CDATA[<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><script type="text/javascript">jQuery.noConflict();</script>]]></text></action></block></reference>
]]>[/box]

The External JS will be added to the <head> tag.

You Might Also Like

  • james rayan

    Hello Gaurav,
    I have a question regarding why javascript file added in header section as per i know javascript file should be added in the footer section so that it perform well, i know magneto follow the fall back modeal too.but i still i can’t understant why ?please give me some satisfactery answer…

    • http://mindgeek.net/ Mindgeek

      You’re right if Javascript is included on footer of the webpage it will be executed after the page is rendered, which doesn’t block the webpage rendering.

      If you want to add this Javascript in Footer, use the following code:

      <![CDATA[jQuery.noConflict();]]>

      Thnx