Hosting your JS at Google

June 16th, 2009 – 21 Comments

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.


21 Responses to Hosting your JS at Google

  1. fareed
    By fareed on 8 November, 2009

    thank u so much for ur great tips and help

  2. Hirvesh
    By Hirvesh on 6 July, 2009

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

  3. john andrews
    By 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/)

  4. Stijn
    By 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).

  5. search24online
    By search24online on 21 June, 2009

    Will try it soon.

  6. observer
    By observer on 21 June, 2009

    thanks Joost… gotta try it now,

  7. tarun
    By tarun on 19 June, 2009

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

  8. rahesg
    By rahesg on 19 June, 2009

    thank u so muchhh

  9. Jason Penney
    By 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. Amazon Discounts
    By 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!

  11. Rich
    By 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.

  12. Peter
    By Peter on 17 June, 2009

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

    • Otto
      By 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.

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

      Yeah, we do :)

  13. HSB
    By 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.

  14. HSB
    By HSB on 16 June, 2009

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

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

      By checking your pages source :)

  15. Kevin Eklund
    By Kevin Eklund on 16 June, 2009

    Another great plugin. Congrats :)

  16. Jim Gaudet
    By Jim Gaudet on 16 June, 2009

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

  17. Christoph C. Cemper
    By Christoph C. Cemper on 16 June, 2009

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

    thanks Joost!


Check out our must read articles about Analytics