Use Google Hosted jQuery in WordPress

So, I recently needed to use a google hosted version of jquery for a WordPress theme (don’t ask). I came across this topic at the WordPress forums.

User bazil749 suggested doing this, I’ve updated it to include jQuery 1.4.4:

<?php
if( !is_admin()){
	wp_deregister_script('jquery');
	wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"), false, '1.4.4');
	wp_enqueue_script('jquery');
}
?>

I added that piece of code to the proper place in the header.php file for the theme and it worked like a champ. jQuery was now loading from Google. The Use Google Libraries plugin does the same basic thing, except it can use libraries other than just jQuery, like jQuery UI, Dojo, MooTools, and Protoype.

There are a number of good reasons to let Google host jQuery for you.