Magento 2 JavaScript – How to Disable JQMigrate Logging

javascriptjquerymagento-2.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

Best Answer

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;