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.

Yoast.com runs on the Genesis Framework

Genesis theme frameworkThe Genesis Framework empowers you to quickly and easily build incredible websites with WordPress. Whether you're a novice or advanced developer, Genesis provides you with the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.

Read our Genesis review or get Genesis now!

21 Responses

  1. Christoph C. CemperBy Christoph C. Cemper on 16 June, 2009

    Wow,. that’s an awesome tip – gonna try this on a couple blogs ASAP

    thanks Joost!

  2. Jim GaudetBy Jim Gaudet on 16 June, 2009

    And Google will update their API pretty quickly, for good or bad…

  3. Kevin EklundBy Kevin Eklund on 16 June, 2009

    Another great plugin. Congrats :)

  4. HSBBy HSB on 16 June, 2009

    I installed the plugin, how do I verify that jQuery is run from Google content network?

    • Joost de ValkBy Joost de Valk on 16 June, 2009

      By checking your pages source :)

  5. HSBBy HSB on 16 June, 2009

    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.

  6. PeterBy Peter on 17 June, 2009

    I love the security leaks this can cause. Everybody trusts Google

    • Joost de ValkBy Joost de Valk on 17 June, 2009

      Yeah, we do :)

    • OttoBy Otto on 17 June, 2009

      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.

  7. RichBy Rich on 17 June, 2009

    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.

  8. Amazon DiscountsBy Amazon Discounts on 17 June, 2009

    Just installed it and saw google’s api url. My pages are quite fast anyway but never hurts to optimise further. Thanks again Joost!

  9. Jason PenneyBy Jason Penney on 18 June, 2009

    Thanks so much for the kind words about my plugin. I’m always glad to hear when people find them useful.

  10. rahesgBy rahesg on 19 June, 2009

    thank u so muchhh

  11. tarunBy tarun on 19 June, 2009

    even i agree with you even i have seen the difference ..

  12. observerBy observer on 21 June, 2009

    thanks Joost… gotta try it now,

  13. search24onlineBy search24online on 21 June, 2009

    Will try it soon.

  14. StijnBy Stijn on 23 June, 2009

    Interesting, but first I’ll have to try and see if it’s compatible with WP-Minify, which compacts my JS (and CSS).

  15. john andrewsBy john andrews on 24 June, 2009

    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/)

  16. HirveshBy Hirvesh on 6 July, 2009

    Already using this technique for my blogger blog! It is awesome and really fast CDN!

  17. fareedBy fareed on 8 November, 2009

    thank u so much for ur great tips and help

Trackbacks

  1. [...] Hosting your JS at Google how to improve your sites performance a bit more by hosting your javascripts with Google (tags: web javascript google api ajax js) Posted by Ogo [...]