• Home
  • New Entries
  • Popular Entries
  • Submit a Story
  • About

Using Google Code libraries with WordPress ...

By default, WordPress loads the version of jQuery that comes with the package. But there is an alternative way of doing it and that’s to use the AJAX Libraries API at Google Code – use their bandwidth, why not…

A few lines added to your functions.php in the theme you’re building and you’re ready to go.

wp_register_script() – the useful point is that you can use this function to access scripts hosted elsewhere…

Just add this code to your functions.php file:
view sourceprint?
01.add_action( emplate_redirect, js_head_load);
02.
03.function js_head_load(){
04.
05.if(is_admin()) return;
06.
07.wp_deregister_script(jquery);
08.wp_register_script(jquery, http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js);
09.wp_enqueue_script(jquery);
10.// and then any other scripts to register and queue...
11.}

Notice the first line of the function ensures that the jQuery isn’t loaded on WP admin pages - if a script isn’t needed, don’t load it on the page – and in this case jQuery in noConflict mode can cause the admin rich text editor and the widget drag and drop interface to go awry..

The advantages:-
You’ll be able to update the version your site is using quickly and easily, probably a good thing.

Google Code tends to have a policy of only including versions demonstrated to be stable, jQuery 1.2.4 and 1.2.5 didn’t make the grade

The user may already have it cached in their browser via some previously visited site instead of downloading from a location on your site (and if enough sites do it, the chances are that much greater that they will have a copy in the cache).

Not just jQuery – check out jQuery UI
http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js
And MooTools, which seems seriously under-used in conjunction with WordPress
http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-yui-compressed.js

Always grab the minified version.

And lastly, one disadvantage:- googleapis.com does go down very occasionally – but then again a site ought to function, more or less, without javaScript.

 Original Source:
http://themocracy.com/2010/02/using-google-code-libraries-with-wordpress/

AddThis Social Bookmark Button

Posted at 01:38:48 pm | Permalink | Posted in How to Blog  

Related Stuff

Google Buzz Button Wordpress Plugin Released

If you are looking for a Google Buzz button to add into your Wordpress site then we have released the first Wordpress plugin exclusively ...

Plug And Play Ecommerce With Wordpress Plugins

Since 2003 Wordpress has slowly been gaining popularity amongst the elite of the internet, the bloggers. It is one of those few things ...

Add Google Search to Your WordPress Blog

The native WordPress search does not return very relevant results, thus it makes a lot of sense to add Google Search into your WordPress ...

Add More Sidebars to Your WordPress Theme

You can add more than one sidebar section to your WordPress site. For example, with the stc-intermountain.org site, I added a whole bunch ...

Series Posting in Wordpress

In my functions.php file, I have some code which implements series posting. This relies on the thematic ...

Top Stuff

Free Blogger templates Anime Themes

Wordpress Guestbook Generator Plugin

48 Unique Ways To Use WordPress

WordPress Single Post Templates

GeekLog

Get The Image WordPress Plugin



About Webloglines

Webloglines is a project offers a comprehensive collection of blogging services, articles, themes and plugins from around the world. Whether you're looking to promote your own blog or find blogs on various topics, this site is for you.


Search


Topics

  • Adsense (12)
  • Blogging Tips (73)
  • Blogs Slides (25)
  • Blogs Websites (22)
  • Digg (20)
  • How to Blog (129)
  • Search Engines (9)
  • SEO (135)
  • WordPress Plugins (269)
  • WordPress Security (75)
  • Wordpress Themes (99)
  • Wordpress Tips (162)

© 2006 www.webloglines.com. All Rights Reserved. Powered by IRange