Skip to content

Instantly share code, notes, and snippets.

@unostar
Last active December 18, 2017 11:10
Show Gist options
  • Save unostar/bfcb6eec2d65ed067449183f0225e802 to your computer and use it in GitHub Desktop.
Save unostar/bfcb6eec2d65ed067449183f0225e802 to your computer and use it in GitHub Desktop.
// Replace bundled WP version of jQuery with the latest one
function replace_core_jquery_version() {
if (!is_admin()) {
wp_deregister_script( 'jquery-core' );
wp_register_script( 'jquery-core', "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js", array(), '3.2.1' );
wp_deregister_script( 'jquery-migrate' );
wp_register_script( 'jquery-migrate', "https://cdnjs.cloudflare.com/ajax/libs/jquery-migrate/3.0.1/jquery-migrate.min.js", array(), '3.0.1' );
}
}
add_action('init', 'replace_core_jquery_version' );
// Dequeue jQuery Migrate script in WordPress
add_action( 'wp_default_scripts', function( $scripts ){
if (!empty($scripts->registered['jquery'])) $scripts->registered['jquery']->deps = array_diff( $scripts->registered['jquery']->deps, array( 'jquery-migrate'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment