updated   : May 15, 2012
we now have 588 snippets
By : , on August 02, 2011 9:00 am

Loading jQuery from the Google CDN with wp_register_script

wordpress snippet

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

snippet :  PHPcopy
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' );
   }
}
  • Gabe

    Aren’t we up to version 1.6.2 with jQuery now?

    • http://wpsnipp.com Kevin Chard

      Whoops thanks Gabe, my bad grabbed an old version, updated!

  • paul

    why do this? not to say it isn’t good I am just not experienced enough.

  • http://popularposting.com google trends

    Nice one I will add this to my blog right away! 

    • http://wpsnipp.com Kevin Chard

      Cool glad to hear you like the snippet.