Annoying "JQMIGRATE: Migrate is..." in console after update to WordPress 4.5

  • Why is there a constant notice,

    JQMIGRATE: Migrate is installed, version 1.4.0

    that points to load-scripts.php in my console when I updated my theme to WordPress 4.5, and how can it be removed?

    It's not an error, but it's always present in my console, and I really don't see what's the point of it. Should I update something, or make some changes to my code?

    Maybe I have a bit of OCD, but usually when I inspect the site, I like to see errors and real notices that point to an issue in my console...

    +1 to your very useful OCD. This probably come from the jquery migration/backward compatibility script. Any chance you use unminified/dev version of it?

    Unminified version of migrate? Not to my knowledge no, it could be some plugins, but upon inspection I don't see any of it :\

    note both versions are in WP dirs: `/wp-admin/js/jquery/jquery-migrate.js` and `/wp-admin/js/jquery/jquery-migrate.min.js`

  • Andy

    Andy Correct answer

    5 years ago

    WordPress uses the jQuery migrate script to ensure backwards compatibility for any plugins or themes you might be using which use functionality removed from newer versions of jQuery.

    With the release of WordPress 4.5, it appears they have upgraded the version of jQuery migrate from v1.2.1 to v1.4.0 - Having a quick scan through the code reveals that v1.4.0 logs that the script is loaded regardless of whether or not the migrateMute option is set and in both the uncompressed and minified versions.

    The only way to remove the notice is to ensure all your plugins/theme code don't rely on any old jQuery functionality, and then remove the migrate script. There's a plugin out there to do this, but it's quite a simple method that can just be placed in your theme's functions file or similar:

    add_action('wp_default_scripts', function ($scripts) {
        if (!empty($scripts->registered['jquery'])) {
            $scripts->registered['jquery']->deps = array_diff($scripts->registered['jquery']->deps, ['jquery-migrate']);
        }
    });
    

    Please note that this is not considered best practice for WordPress development and in my opinion the migrate script should not be removed just for the sake of keeping the developer console clean.

    So basically one of my plugins is depending on a functionality that was a part of the old jQuery version? Is there a way to find out what that functionality is? Or am I safe to just mute the migrate script?

    I can't say for sure whether any of your plugins depend on old functionality, WordPress just includes the migrate script as a safe default in case your install has any plugins which haven't been updated in a while. If it were me I'd remove the migrate script on a local install of the site and then check everything still works as expected, ensuring there are no errors in the console etc.

    I recommend against this. This backwards compatibility is there for a reason. It is the jQuery equivalent of deleting deprecated functions file in WordPress. Going to all the trouble of verifying whether your *current* setup is fully compatible does not even account for changes of setup or plugin additions, and given the potential problems you'd be creating does not balance against the completely dubious benefit of removing a console log message.

    @majick It's beyond the scope of this answer to discuss whether removing the script is a good idea or not, this specifically addresses the issue of how to remove the message in the console. FWIW, I think removing the script is a bad idea also. I think the downvote is uncalled for, as my answer perfectly answers the OPs question.

    sorry I don't downvote often, but felt it was needed here as there is no warning that this may not be a good idea and is the opposite of best practice in development (add a warning and i'll remove the downvote.) I believe the question is asking how to remove just the console message not how to remove jquery migrate itself. if someone asked how to remove the update nag message in WordPress you wouldn't answer "just uninstall WordPress."

    @majick warning added. You're right in that the question is asking how to remove the console message, my answer states that the only way to remove the message is to remove the script, which is true unless you go down the route of rewriting native browser functions as per your answer.

    no probs, downvote removed. for myself, if it really annoyed me, I'd prefer to just comment out the message in the migrate js file each WP upgrade over removing it entirely anyway. just because javascript is pretty temperamental, sometimes one thing out of place and almost everything breaks.. that is just too much of a risk with no gain when this is specifically in place to avoid that.

    This error message is annoying but removing it on every new site is a waste of time. It would be great if somewhere we could kindly ask a developer whoever put the message there in Wordpress to remove it in next release :)

    @IvanTopić It wasn't added by any WordPress developers, it was added by the jQuery team. By the looks of things it's not something they're going to remove either: https://github.com/jquery/jquery-migrate/issues/149

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM