Skip to main content
Add correct URL to snippet. Add reference.
Source Link
tommypyatt
  • 228
  • 2
  • 9

You can load jQuery from a CDN with the following layout XML, placed within your <default> handle in local.xml or other layout XML file:

<reference name="head">
    <block type="core/text" name="head.jquery">
        <action method="setText">
            <text><![CDATA[<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><script>window.jQuery||document.write('<script src="/path/toajax.googleapis.com/yourajax/libs/jquery/3.3.1/jquery.min.js">\x3c/script>');</script><script>jQuery.noConflict();</script>]]></text>
        </action>
    </block>
</reference>

Replace the version/URL accordingly.

Is it worthwhile?

Whether or not you will get much of doing this is debatable.

In my experience I've found that it's generally better not to do this; jQuery's size after gzipping is pretty minimal compared to things like product images, and it can slow down local development if you have connection problems while working.

Note: code snippet taken from answer to this question, which appears to be valid.

You can load jQuery from a CDN with the following layout XML, placed within your <default> handle in local.xml or other layout XML file:

<reference name="head">
    <block type="core/text" name="head.jquery">
        <action method="setText">
            <text><![CDATA[<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><script>window.jQuery||document.write('<script src="/path/to/your/jquery.js">\x3c/script>');</script><script>jQuery.noConflict();</script>]]></text>
        </action>
    </block>
</reference>

Replace the version/URL accordingly.

Is it worthwhile?

Whether or not you will get much of doing this is debatable.

In my experience I've found that it's generally better not to do this; jQuery's size after gzipping is pretty minimal compared to things like product images, and it can slow down local development if you have connection problems while working.

You can load jQuery from a CDN with the following layout XML, placed within your <default> handle in local.xml or other layout XML file:

<reference name="head">
    <block type="core/text" name="head.jquery">
        <action method="setText">
            <text><![CDATA[<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><script>window.jQuery||document.write('<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">\x3c/script>');</script><script>jQuery.noConflict();</script>]]></text>
        </action>
    </block>
</reference>

Replace the version/URL accordingly.

Is it worthwhile?

Whether or not you will get much of doing this is debatable.

In my experience I've found that it's generally better not to do this; jQuery's size after gzipping is pretty minimal compared to things like product images, and it can slow down local development if you have connection problems while working.

Note: code snippet taken from answer to this question, which appears to be valid.

Source Link
tommypyatt
  • 228
  • 2
  • 9

You can load jQuery from a CDN with the following layout XML, placed within your <default> handle in local.xml or other layout XML file:

<reference name="head">
    <block type="core/text" name="head.jquery">
        <action method="setText">
            <text><![CDATA[<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><script>window.jQuery||document.write('<script src="/path/to/your/jquery.js">\x3c/script>');</script><script>jQuery.noConflict();</script>]]></text>
        </action>
    </block>
</reference>

Replace the version/URL accordingly.

Is it worthwhile?

Whether or not you will get much of doing this is debatable.

In my experience I've found that it's generally better not to do this; jQuery's size after gzipping is pretty minimal compared to things like product images, and it can slow down local development if you have connection problems while working.