Loading jQuery from the Google CDN with wp_register_script

Adding this snippet to the functions.php of your wordpress theme will register and include jquery from the Google CDN.

 

 

add_action( 'init', 'jquery_register' );
function jquery_register() {
if ( !is_admin() ) {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', ( 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js' ), false, null, true );
wp_enqueue_script( 'jquery' );
}
}

Be Sociable, Share!

Leave a comment