Created
November 14, 2016 15:36
-
-
Save petersplugins/4d438a47f79007de68bd91f06e5afcad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This code snippet replaces the link to the locally hosted jQuery core with the link to the jQuery core hosted on jQuery CDN | |
// This reduces server load and page load time | |
// We do not use wp_deregister_script and wp_register_script but we directly access the global variable $wp_scripts | |
// because we want to replace the script with the correct version number | |
add_action( 'wp_print_scripts', 'replace_jquery' ); | |
function replace_jquery() { | |
global $wp_scripts; | |
$wp_scripts->registered['jquery-core']->src = 'https://code.jquery.com/jquery-' . $wp_scripts->registered['jquery-core']->ver . '.min.js'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment