Wordpress: using the Google CDN version of jQuery

Using the Google CDN's version of jQuery with Wordpress is a task that requires only a slight change in your functions.php file. The only thing we have to check is that we're not viewing the Wordpress backend, where the default jQuery version is required. Let's see the code:

if( !is_admin()){
   wp_register_script('jquery', ('http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'), false, '1.6.2'); 

You can change the second parameter of the wp_register_script() to any value you want. In this case we're using the latest version of jQuery. The fourth parameter, instead, is optional but it's highly recommended to avoid any possible conflict between the various library versions.

Leave a Reply

Note: Only a member of this blog may post a comment.