Hosting your JS at Google
While in a previous post I talked about WordPress database optimization, with this post I intend to show you how to improve your sites performance a bit more by hosting your javascripts with Google.
This only works if you're using jQuery, prototype or another library that is supported by Google's AJAX Librararies API.
While those javascript libraries are included with WordPress and WordPress can already serve them in a reasonably efficient way, there's an even better solution: use the Google Libraries plugin.
This plugin makes use of said API, serving the files out from Google's content distribution network. No matter how fast your hosting is, even with my super WordPress hosting and MaxCDN WordPress CDN setup I'm willing to bet that Google's CDN is faster.
Don't believe me? Here are 3 more reasons.





by Christoph C. Cemper on 16 June, 2009 at 14:16
Wow,. that's an awesome tip - gonna try this on a couple blogs ASAP
thanks Joost!
by Jim Gaudet on 16 June, 2009 at 15:24
And Google will update their API pretty quickly, for good or bad...
by Kevin Eklund on 16 June, 2009 at 18:22
Another great plugin. Congrats :)
by HSB on 16 June, 2009 at 21:13
I installed the plugin, how do I verify that jQuery is run from Google content network?
by Joost de Valk on 16 June, 2009 at 21:41
By checking your pages source :)
by HSB on 16 June, 2009 at 21:46
I checked the source page after I installed, but I didn't clear the cache.
But, I can see it load from Google Content Library after I cleared the browser's cache.
From Page Source
Thanks.
Pingback: links for 2009-06-16 - Ogo
by Peter on 17 June, 2009 at 11:51
I love the security leaks this can cause. Everybody trusts Google
by Joost de Valk on 17 June, 2009 at 12:54
Yeah, we do :)
by Otto on 17 June, 2009 at 22:42
Well, yes, everybody trusts Google's CDN because it serves up (last I checked) something like 17% of all the internet's web traffic. That's a fair amount of traffic and I sort of expect them to get it right because of that.
by Rich on 17 June, 2009 at 16:19
We've used the plugin for a while now. Works fine. It would be even better if it moved the Google script request to the bottom of the page so not to speed up page load times even further.
by Amazon Discounts on 17 June, 2009 at 17:40
Just installed it and saw google's api url. My pages are quite fast anyway but never hurts to optimise further. Thanks again Joost!
by Jason Penney on 18 June, 2009 at 19:37
Thanks so much for the kind words about my plugin. I'm always glad to hear when people find them useful.
by rahesg on 19 June, 2009 at 05:51
thank u so muchhh
by tarun on 19 June, 2009 at 10:56
even i agree with you even i have seen the difference ..
by observer on 21 June, 2009 at 00:17
thanks Joost... gotta try it now,
by search24online on 21 June, 2009 at 09:29
Will try it soon.
by Stijn on 23 June, 2009 at 14:31
Interesting, but first I'll have to try and see if it's compatible with WP-Minify, which compacts my JS (and CSS).
by john andrews on 24 June, 2009 at 05:13
Not everyone trusts Google that much, because this method does give Google info on every visitor to your site (referrer, IP, etc) to the extent they pull the library. I addressed this at http://www.johnon.com/647/google-ajax-api.html and got some responses from Ben Lisbakken of Google.
As for speed and reliability, the comments in the article you link to actually demonstrate it is NOT yet a good idea to rely on Google's CDN (see recent comments at http://encosia.com/2008/12/10/3-reasons-why-you-should-let-google-host-jquery-for-you/)
by Hirvesh on 6 July, 2009 at 10:34
Already using this technique for my blogger blog! It is awesome and really fast CDN!
by fareed on 8 November, 2009 at 20:30
thank u so much for ur great tips and help