I’m doing it right now with the following code:
function uw_load_scripts() {
// De-register the built in jQuery
wp_deregister_script('jquery');
// Register the CDN version
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', array(), null, false);
// Load it in your theme
wp_enqueue_script( 'jquery' );
}
add_action( 'wp_enqueue_scripts', 'uw_load_scripts' );
This works, but should I do this for everyone, like this, or for everyone but admin (so that backend uses the WordPress version?):
if (function_exists('load_my_scripts')) {
function load_my_scripts() {
if (!is_admin()) {
wp_deregister_script( 'jquery' );
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', array(), null, false);
wp_enqueue_script('jquery');
}
}
}
add_action('init', 'load_my_scripts');
This version doesn’t work at all actually, I get the WordPress jQuery-version and not the Google one.
Therefore, should I deregister the jQuery that is included in WordPress at all?
Also, how do I add my own scripts (slider scripts, modernizr and my own custom.js) the correct way? I guess I should do this via functions.php as well and not in the header like I’m doing it now, but I’m unsure of how I would do that.