1

We keep receiving this log and stack trace from JQMigrate, but it seems to just be a warning. Is there a way to just straight up disable logging in production?

enter image description here

3

I ended up overriding the core jquery-migrate in our theme so I could set the migrateMute option.

In my theme require-jsconfig.js I set this override:

var config = {
  paths: {
    // disable jQuery migrate console output
    'jquery/jquery-migrate': 'js/jquery-migrate'
  }
}

Then copied the code jquery-migrate.js file to the theme js directory, and added this line towards the top:

// Set to true to prevent console output; migrateWarnings still maintained
jQuery.migrateMute = true;
  • Going to mark this as the selected answer, as it's a bit cleaner than the first method that was given. – codestr Feb 5 '18 at 22:17
  • This helped, but didn't hide everything for me; I also had to include jQuery.migrateTrace = false; – user7290573 Apr 18 at 9:15
4

In order not to overwrite any magento core files I just created a javascript file with this code

require(
    ['jquery'],
    function ($) {
        $.migrateMute = true;
        $.migrateTrace = false;
    }
);

I included the file in the head in default.xml

<link src="js/disable-jquery-migrate-warnings.js" />
1

A little bit hacky way but it works. You can create requirejs-config.js file in your theme and reassign jquery-migrate to an empty file

Example:

var config = {
    paths: {
        'jquery/jquery-migrate': 'js/empty'
    },
};

and create empty file js/empty.js

  • This works and I'll mark as accepted since its the only solution thats been offered, but I'd rather avoid having to make the request for the file at all if it's not going to be used. – codestr Nov 28 '17 at 15:19
0

The solution posted by @thaddeusmt works great but I found an even better one. If you already have a js file you include everywhere, you can just add this to the top:

require(['jquery'], function($) {
    $.migrateMute = true;
});

so it looks something like this:

require(['jquery'], function($) {
    $.migrateMute = true;
});
// the rest of the js file...
require([
    "jquery",
    "jquery/ui",
    "mage/translate",
    "domReady!",
    "Magento_Ui/js/modal/modal"
], function ($) {
    // ...
});
0

One should mute jquery.migrate before it gets initialised.

js/mute-migrate.js

requirejs(['jquery'], function ($) {
    $.migrateMute = true;
    $.migrateTrace = false;
});

requirejs-config.js

var config = {
    paths: {
        "mute-migrate":"js/mute-migrate"
    },
    shim: {
        'jquery/jquery-migrate': ['jquery','mute-migrate']
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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