52

Google Ajax Libraries API & How To Save On Your Wordpress Bandwidth

Posted December 28th, 2008 by Jeremy Schoemaker

Did you know Google hosts various JavaScript library for you? They currently support:

Just looking at November stats for this blog ShoeMoney.com you can see we have used over 6 gigabytes of bandwidth calling the jquery JavaScript library:

Now honestly I don’t care about the bandwidth savings… my bill is the same if I did not use this but I do care about security and I am much more inclined to believe Google will have a up to date, secure version hosted then the one that wordpress installs (and I forgot to update).

I wonder why Wordpress does not use the Google hosted JavaScript libraries by default. Its one less thing they would have to worry about in regards to version, security, and bandwidth for its users.

From the official Google Ajax Libraries API site:

The AJAX Libraries API is a content distribution network and loading architecture for the most popular, open source JavaScript libraries. By using the Google AJAX API Loader’s google.load() method, your application has high speed, globaly available access to a growing list of the most popular, open source JavaScript libraries including:

And here is a movie from their developers on youtube:

Good stuff Google!

Disclaimer

Before acting on this post, be sure to read my Disclaimer.

- Comment Likes - Comment Dislikes

52 comments. What say you?

  1. Good Comment?
    Penis Enlargement

    I think you are thinking like sukrat, but I think you should cover the other side of the topic in the post too…

  2. Good Comment?
    Mr. School Fundraising Ideas

    Really Google host something that Yahoo owns… is it just me or is that weird?

  3. Good Comment?
    Ulrich

    Thats why I love this blog.

  4. Good Comment?
    sai

    Very good to hear that they support ajax API for shared. M really planning to buy a package for me and dorp the dedicated

  5. Good Comment?
    Blog And Make Cash

    Excellent! Thanks for the info, I didn’t know you can do that!

  6. Good Comment?
    Blog And Make Cash

    Excellent! I didn’t knew you can do that…Thanks for the info!

  7. Good Comment?
    Chris Bartow

    You can also save bandwidth by using mod_expires to make users cache files that aren’t going to change longer.

    ExpiresActive on
    ExpiresDefault “access plus 1 month”

  8. Good Comment?
    Dick

    I stand for variety of companies, brands, services,opportunities and etc. A person must have a choice and choose according to its tastes, desires and finances.

  9. Good Comment?
    Johan Cyprich

    The problem with these hosted libraries is that Google will update them, not you. The plugins on your blog may work well with a library, but when the library is updated, the plugin may fail to work. Its better to host everything on your server so you can thoroughly test upgrades to determine if they are safe.

    • Good Comment?
      Wesley

      Google keeps separate files for each version update from jquery, etc.. So you can just include jquery 1.2.6 and it won’t be updated, ever.

  10. Good Comment?
    SEO

    Thanks off post.

    Happy 2009.

  11. Good Comment?
    Wesley

    Can anyone tell me if google ajax libraries is set up like a CDN (content delivery network)? e.g. if I live in Canada, do I get the javascript from a canadian server, if from Europe, from a European server?

    If so, that would be an additional benefit to using this, as it would result in faster javascript downloads. Plus, once it’s downloaded, the javascript should remain in cache, even on other sites who reference the same file.

    You can also accomplish this using google app engine, but for much more, like images, etc.. though I think doing this is a bit borderline.. google could easily delete the account if all you are doing is using their bandwidth.

    See http://24ways.org/2008/using-google-app-engine-as-your-own-cdn for info on how to do this.

  12. Good Comment?
    JustChecking

    Google is the Nazi Germany/Roman Empire of the internet. As history always plays out the bigger they are the harder they fall. The evil Google empire will fall in time.

    • Good Comment?
      Steve

      Absolutely right, they control everything on the net.

    • Good Comment?
      TYCP Entertainment Magazine

      Nazi Germany? What would we call this? Google committing Webicide?

  13. Good Comment?
    Nicholas

    Peter, why is your comment almost exactly like mine?

  14. Good Comment?
    Steven-Sanders

    Interesting information, but I agree with the idea of not putting all your eggs in one basket.

    Google will continue to grow and continue to provide anything and everything it can in the process.

    If users start using everything from Google, what happens if Google ever goes away?

    There is something to be said for a savings of 6GB of bandwidth, but not if it lends itself to putting everything you have into Google’s hands.

  15. Good Comment?
    Peter

    Actually worried about the Google “data collection” as well. But if you do decide to use these, make sure you put in code to put the proper HTTP prefix in; if you try to load a JS include from http, but your user is currently in HTTPS, you’ll get errors in some browsers.

  16. Good Comment?
    Dave Ward

    To those who are paranoid about privacy, keep in mind that Google sets an expires header of +1 year on these libraries. So, if it’s already in your cache, the browser won’t make a request to Google at all, not even to check for a 304.

    If Google were truly doing this for purposes of tracking, they’d not set that expires header.

    I wrote a post about this recently which you may find useful. It’s specifically about jQuery, but everything mentioned applies equally to any of the libraries that Google hosts: http://encosia.com/2008/12/10/3-reasons-why-you-should-let-google-host-jquery-for-you/

  17. Good Comment?
    megachamp

    More then 6 gb is way too much. Something is fishy.

  18. Good Comment?
    Nicholas

    I’m worried about the Google “data collection” as well. But if you do decide to use these, make sure you put in code to put the proper HTTP prefix in; if you try to load a JS include from http, but your user is currently in HTTPS, you’ll get errors in some browsers.

  19. Good Comment?
    jtGraphic

    Is Google’s agenda to collect data with this?

    • Good Comment?
      Mihai Secasiu

      That would be just one possible use of this. They would be stupid not to collect data. The more they know the better they can target their ads.

    • Good Comment?
      TYCP Entertainment Magazine

      Didn’t think about that until you mentioned it. Interesting point…

  20. Good Comment?
    joe gelb

    those are deffinitely overlooked internet secrets

  21. Good Comment?
    Buscador

    Muy bueno el articulo, me gusto y esta muy clarito las librerias de AJAX. Que por cierto, nos va a ayudar mucho.

    Suerte

    • Good Comment?
      Taris Janitens

      Holy Spanish batman!!!! Maybe translate it to english as most of the readers of the blog are english speaking?? Unless I was mistaken as to the popularity of Shoemoney in Spanish social circles :)

  22. Good Comment?
    LGR

    I have wondered this as well when I heard about Google hosting the AJAX libraries. Not only would it save on bandwidth, the files would get cached by the browsers and any site using the Google hosted libraries would load much faster.

    • Good Comment?
      Mihai Secasiu

      The idea seems nice. Having it done by google not so nice. People tend to move everything to google and that’s just a bad idea. One big corporation controlling all of your assets is really bad. The web, internet and “everything else” work so well because they are distributed so keep them like that people, don’t do things you might regret for a few megs of bw savings.
      Sure on shoemoney.com that’s almost 6Gb but it’s still just 2.77% of the total bw savings. I think the percents matter more.

    • Good Comment?
      anty

      The caching is probably the most important reason why you should use googles (or yahoos) hosted JS libraries. Once a user access a site that uses one of those hosted libraries, they will never need to load them again, regardless which site they access.

      I disagree with the security reason Jeremy gave, because you have a directory for each version you want to load on the google servers. So if there’s an update of the library you need to manually switch to the new version.

    • Good Comment?
      BusinessX

      Agreed about faster. Using flikr for graphics, google for ads, my pages load much quicker, plus the bandwidth savings.

  23. Good Comment?
    Taris Janitens

    Definitely a useful writeup!!! A bit complicated for my blood tho hehehe

  24. Good Comment?
    jim

    Very useful tip, I’d imagine that Google’s servers are probably more robust than the ones my host are!

  25. Good Comment?
    Ann Mobile

    Very interesting (article & video)

  26. Good Comment?
    The Poker Jerk

    Thanks Google, for making our lives better in so many ways :)

  27. Good Comment?
    meethere

    That would save a lot of bandwidth for small shared hosting.
    Thanks for sharing.. will do the changes. :)

  28. Good Comment?
    Wesley

    There’s a plugin that should handle this, but I haven’t tested it myself yet:

    http://wordpress.org/extend/plugins/use-google-libraries/ (requires php5)

    • Good Comment?
      jtGraphic

      @Shoemoney

      Thanks a ton, this is exactly why I subscribe to this blog. This is a great thing. I’m always looking for ways to increase performance, and this is exactly the kind of thing that helps me.

      @Wesley

      Thanks for the tip. That just extends the coolness of how useful this post is.

    • Good Comment?
      nqm

      someone have tested it?

  29. Good Comment?
    Learn English Online

    Wordpress and Google are rivals. Google supports blogger and recently bought a South Korean Internet company (I don’t remember the name now) in order to compete with Wordpress. Maybe that’s why Wordpress doesn’t want to use Google services as well! ;)

Join the Discussion