WordPress最近发现有个jQuery Migrate的js引入,但其实我的主题是用不上的,解决办法也很简单,functions.php加如下代码即可:

function remove_jquery_migrate( $scripts ) {
if ( ! is_admin() && isset( $scripts->registered['jquery'] ) ) {
$script = $scripts->registered['jquery'];
if ( $script->deps ) {
// Check whether the script has any dependencies

$script->deps = array_diff( $script->deps, array( 'jquery-migrate' ) );
}
}
}
add_action( 'wp_default_scripts', 'remove_jquery_migrate' );

相关参考:

How to Remove jQuery Migrate in WordPress?



Related Posts: WordPress如何移除jQuery Migrate :

留言