I want to load the latest version (v3.2.1) jquery in my Magento 2 custom module.

Actually, I want to use materializes in luma theme but for that jquery version must be 3.2.1. I tried to replace the current version with the new one but I got other jquery errors.

So I want to load the latest version only in my custom module.

Anyone know how to do it?

  • 1
    On frontend or backend ? You can use requirejs to load your custom jquery
    – Keyur Shah
    Sep 28, 2017 at 12:26

1 Answer 1


Method 1: JS override

You can override the original jQuery file to the one you desired. If you have an own theme, you can put the latest jquery.js file into app\design\frontend\Vendor\Theme\web\js\. The system will use your jQuery file instead.

Ref: How to change jQuery version in Magento2

Method 2: Use CDN

It also override the original theme JS file, and using your theme files. But this time, we don't download the jquery.js file. We always get the latest one.

  1. Go to app\design\frontend\Vendor\Theme\Magento_Theme\layout\default_head_blocks.xml. You can create this file if you don't have.

  2. Add the following code on the file

    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <!--Remove default jquery, or it will cause conflict-->
        <remove src="lib\web\jquery.js"/>
        <!--Include CDN-->
              crossorigin="anonymous" src_type="url"></script>

You can change to any jQuery versions as you want. For the <script> part, you can refer to https://code.jquery.com/ . And, remember to add src_type="url" before closing tag.

  1. If you have enabled cache, clear the cache.

Ref: http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/xml-manage.html#layout_markup_css_remove

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.