admin管理员组文章数量:1302871
I am managing this blog.
As you can see, it loads both jquery.js?ver=1.12.4
and jquery-migrate.min.js?ver=1.4.1
Do I need both of them, or I can safely remove one of them? Isn't the jquery-migrate.min.js
the newest version of jquery.js?
How do I know if I can remove one of them or not?
I am managing this blog.
As you can see, it loads both jquery.js?ver=1.12.4
and jquery-migrate.min.js?ver=1.4.1
Do I need both of them, or I can safely remove one of them? Isn't the jquery-migrate.min.js
the newest version of jquery.js?
How do I know if I can remove one of them or not?
Share Improve this question edited Feb 28, 2018 at 5:14 Marc 7315 silver badges15 bronze badges asked Jul 5, 2017 at 17:51 PikkPikk 2791 gold badge6 silver badges14 bronze badges2 Answers
Reset to default 8As stated in the official blog of jQuery. Note that WordPress is mentioned in the quote.
jQuery Migrate 1.4.1 released, and the path to jQuery 3.0
Version 1.4.1 of the jQuery Migrate plugin has been released. It has only a few changes but the most important of them fixes a problem with unquoted selectors that seems to be very common in some WordPress themes. In most cases Migrate can automatically fix this problem when it is used with jQuery 1.12.x or 2.2.x, although it may not be able to repair some complex selectors. The good news is that all the cases of unquoted selectors reported in WordPress themes appear to be fixable by this version of Migrate!
A quick answer to your question; yes you can remove the jQuery migration script and if you don't see any unwanted behavior after the removal of the script, then it's safe to say that you can completely remove the reference migration script.
Can be read in here
Yes you can remove JQuery Migrate to speed up the loading of your page on the client side.
What is jQuery Migrate?
The jQuery Migrate module (jquery-migrate.min.js) is a javascript library that allows you to preserve the compatibility of your jQuery code developed for versions of jQuery older than 1.9. JQuery Migrate also allows developers to detect deprecated code that is no longer supported by the latest jQuery libraries and to adapt it according to the newest versions of jQuery 1.9 and higher.
PHP code to disable jQuery Migrate in WordPress
This is the code I'm using for my clients and it is the right way to remove it properly on the client side without affecting any other components in the WordPress Dashboard. Grab this code and paste it in your functions.php file to remove the JQuery:
/**
* Disable jQuery Migrate in WordPress.
*
* @author Guy Dumais.
* @link https://en.guydumais.digital/disable-jquery-migrate-in-wordpress/
*/
add_filter( 'wp_default_scripts', $af = static function( &$scripts) {
if(!is_admin()) {
$scripts->remove( 'jquery');
$scripts->add( 'jquery', false, array( 'jquery-core' ), '1.12.4' );
}
}, PHP_INT_MAX );
unset( $af );
Hope this helps!
本文标签: Do I need both jqueryjs and jquerymigrateminjs
版权声明:本文标题:Do I need both jquery.js and jquery-migrate.min.js? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741721809a2394435.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论