1

I keep seeing this warning in my console (firefox dev-console)

JQMIGRATE: jQuery.browser is deprecated jquery-migrate.js:41:4
console.trace(): jquery-migrate.js:43
 migrateWarn ---.com/static/version1498093005/frontend/Magento/luma/en_US/jquery/jquery-migrate.js:43:5
 get ---.com/static/version1498093005/frontend/Magento/luma/en_US/jquery/jquery-migrate.js:58:6
 f< ---.com/static/version1498093005/frontend/Magento/luma/en_US/jquery/jquery.ba-hashchange.min.js:9:677
 <anonymous> ---.com/static/version1498093005/frontend/Magento/luma/en_US/jquery/jquery.ba-hashchange.min.js:9:389
 <anonymous>

I'd really like to update it to a newer version. Thanks

asked Jun 22, 2017 at 19:09

1 Answer 1

3

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">
    <head>
     <!--Remove default jquery, or it will cause conflict-->
     <remove src="lib\web\jquery.js"/>
     <!--Include CDN-->
     <script
     src="https://code.jquery.com/jquery-3.2.1.min.js"
     integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
     crossorigin="anonymous" src_type="url"></script>
    </head>
    

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

Khoa Truong
32.5k11 gold badges91 silver badges159 bronze badges
answered Jun 23, 2017 at 3:42
3
  • 1
    What about the require js dependency id of jQuery when you change the filename from jquery.js to jquery-3.2.1.min.js? Commented Jun 18, 2018 at 7:24
  • Also method #1 does not work for magento version 2.2.4 Commented Jun 18, 2018 at 7:32
  • @FrankGroot, you found any answer for this? Commented Sep 9, 2021 at 13:50

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.