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

by Jeremy Schoemaker on December 28, 2008 · 57 comments

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!

About the author...

– who has written 2412 posts on ShoeMoney.com.

Hi I am Jeremy Schoemaker and ShoeMoney.com is my blog. 99% of the post here are done by me but you will see others occasionally make guest posts. This blog is fun to write but for my day job I run several online companies.

Images provided by ShutterStock


Mark recommends you read these posts also:

  1. shutterstock_67747240 Don’t Worry – People Know
  2. money Sneaky Facebook Advertising Tricks – Dialing In Your Campaigns Part 2
  3. RandyCouture The Perfect Business

{ 52 comments… read them below or add one }

1 Learn English Online December 28, 2008 at 6:19 am

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! ;)

Reply

2 Jeremy Schoemaker December 28, 2008 at 10:55 am

Wordpress already uses a lot of Google Features some even much more immature. (like google gears)

Reply

3 Mihai Secasiu December 28, 2008 at 11:08 am

I think gears is the only feature that wordpress is actually using.
And this is totally different then gears.

Reply

4 Blog Expert December 28, 2008 at 11:29 am

Agree!

Reply

5 Internet Marketing Industry December 28, 2008 at 1:30 pm

Thanks for sharing Jeremy….and also just for the rest there is a plug in that would handle the task for you heres the link. http://wordpress.org/extend/plugins/use-google-libraries/

Reply

6 TYCP Entertainment Magazine December 30, 2008 at 12:40 am

I figured there was a plugin for this. Thanks for the link.

Reply

7 Wesley December 28, 2008 at 6:40 am

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)

Reply

8 jtGraphic December 28, 2008 at 9:53 am

@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.

Reply

9 nqm December 28, 2008 at 11:29 am

someone have tested it?

Reply

10 meethere December 28, 2008 at 6:50 am

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

Reply

11 The Poker Jerk December 28, 2008 at 6:54 am

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

Reply

12 Ann Mobile December 28, 2008 at 7:37 am

Very interesting (article & video)

Reply

13 jim December 28, 2008 at 7:58 am

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

Reply

14 Taris Janitens December 28, 2008 at 8:11 am

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

Reply

15 Typhoon December 31, 2008 at 3:38 am

yea me too…

Reply

16 The Poker Jerk December 31, 2008 at 5:50 am

Yeah me too! I felt the need to tell everyone that.

Reply

17 LGR December 28, 2008 at 8:16 am

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.

Reply

18 Mihai Secasiu December 28, 2008 at 9:42 am

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.

Reply

19 anty December 28, 2008 at 5:08 pm

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.

Reply

20 BusinessX December 28, 2008 at 7:54 pm

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

Reply

21 TYCP Entertainment Magazine January 3, 2009 at 8:21 am

I thought that Flickr charges a fee if you want a certain amount of pictures uploaded?

Reply

22 Buscador December 28, 2008 at 9:41 am

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

Suerte

Reply

23 Taris Janitens December 28, 2008 at 1:19 pm

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

Reply

24 joe gelb December 28, 2008 at 9:54 am

those are deffinitely overlooked internet secrets

Reply

25 jtGraphic December 28, 2008 at 9:57 am

Is Google’s agenda to collect data with this?

Reply

26 Mihai Secasiu December 28, 2008 at 10:14 am

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.

Reply

27 TYCP Entertainment Magazine December 30, 2008 at 1:18 am

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

Reply

28 Nicholas December 28, 2008 at 10:14 am

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.

Reply

29 megachamp December 28, 2008 at 10:35 am

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

Reply

30 Dave Ward December 28, 2008 at 11:23 am

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/

Reply

31 Peter December 28, 2008 at 12:09 pm

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.

Reply

32 Steven-Sanders December 28, 2008 at 1:22 pm

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.

Reply

33 Nicholas December 28, 2008 at 2:39 pm

Peter, why is your comment almost exactly like mine?

Reply

34 JustChecking December 28, 2008 at 3:29 pm

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.

Reply

35 Steve December 28, 2008 at 5:47 pm

Absolutely right, they control everything on the net.

Reply

36 TYCP Entertainment Magazine December 30, 2008 at 1:20 am

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

Reply

37 Wesley December 28, 2008 at 4:29 pm

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.

Reply

38 SEO December 28, 2008 at 6:27 pm

Thanks off post.

Happy 2009.

Reply

39 Johan Cyprich December 28, 2008 at 7:19 pm

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.

Reply

40 Wesley December 29, 2008 at 2:27 am

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.

Reply

41 Dick December 29, 2008 at 12:23 am

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.

Reply

42 Chris Bartow December 29, 2008 at 9:05 am

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”

Reply

43 Blog And Make Cash December 30, 2008 at 2:24 am

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

Reply

44 Blog And Make Cash December 30, 2008 at 2:24 am

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

Reply

45 sai January 3, 2009 at 12:49 am

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

Reply

46 Ulrich January 3, 2009 at 2:14 pm

Thats why I love this blog.

Reply

47 Mr. School Fundraising Ideas January 9, 2009 at 10:41 am

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

Reply

48 Penis Enlargement January 21, 2009 at 7:41 am

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

Reply

49 divemaster February 12, 2011 at 6:38 pm

Thanks , I’ve just been searching for info about this subject for ages and yours is the best I’ve discovered till now. But, what about the conclusion? Are you sure about the source?

Reply

50 Sprawy rozwodowe February 26, 2011 at 11:15 am

Interesting! I liked your information:) It would be nice if you could to write a little more often, greetings from Poland :)

Reply

51 John February 28, 2011 at 4:21 am

Good day! I just would like to give a huge thumbs up for the good info you have got right here on this post. I will be coming again to your blog for more soon.

Reply

52 black chair April 2, 2011 at 11:23 am

I was just seeking this info for a while. After 6 hours of continuous Googleing, finally I got it in your website. I wonder what’s the lack of Google strategy that don’t rank this type of informative websites in top of the list. Generally the top sites are full of garbage.

Reply

Leave a Comment

Previous post:

Next post: