Skip to content

Why is Google hosting common Javascript/AJAX Libraries?

Why is Google hosting common Javascript/AJAX Libraries?

This post will be published to the public later today, with a unique URL (/google-ajax-api.html) and the above title.Thanks for reading and following.

I have a question I would like to try and answer, and I need some help. Why is Google hosting popular Javascript/AJAX libraries like jQuery, Prototype,, MooTools, Dojo, SWFObjectNew!, and even user interface libraries like the Yahoo! User Interface Library (YUINew!) and jQuery UI?

My follow up question is why website developers are making use of those hosted services, but first I need to understand Google’s intent.

Perhaps you didn’t know (because you are an SEO and not a coder, or an owner and not a coder) that your website is loading its javascript libraries off of Google’s servers, every single time they are needed. Google offers this seemingly benevolent service for free (read the offer here).

Perhaps you didn’t realize that under this arrangement, Google can see the IP and referrer of every incoming visitor. Is this just another way that Google can see your web traffic, and where it is coming from? I need to understand this better.

You can tell if your coder is utilizing this service (and handing Google the keys to your business data) by inspecting the source code of your web page, looking for something like (the “XXX” partwill vary):

<script src=""></script>

This is definitely a helpful thing for developers — it makes their job easier, and we know developers love things that make their jobs easier. Google presents it that way to developers:

The AJAX Libraries API takes the pain out of developing mashups in JavaScript while using a collection of libraries. We take the pain out of hosting the libraries, correctly setting cache headers, staying up to date with the most recent bug fixes, etc.

Google is indeed hosting the libraries, but Google is also helping the makers of those libraries, since having your library hosted and distributed (and promoted) by Google can’t be a bad thing:

Google works directly with the key stake holders for each library effort and accepts the latest stable versions as they are released. Once we host a release of a given library, we are committed to hosting that release indefinitely.

This all sounds so… good. Google does try to suggest that this is also good for web publishers, when it states:

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

I questioned the “load faster” part, because I prefer to rely on my own servers (thank-you-very-much). Alex noted below that load times can be reduced due to paralel loading of libraries from different servers, in addition to any benefits from Google’s caching and data center performance.

I doubt many business decision makers are actually in tune with this at all. Is it an issue? Developers are making the call here.  So why is Google being so benevolent?

Brian notes in a comment that Google can trust the js libraries since it hosts them… and doesn’t need to crawl through them to know what’s inside. Excellent point. What do you think?

Take a look at that SWFObject one, too. Wow.. why would Google want to host in real time the javascript library that is most commonly used for  managing embedded Flash objects with alternative text annotations?

Does anyone know? Please comment.

Google’s done covert things before. I recall when we learned, well after the fact, that Mozilla had taken nearly a hundred million of dollars from Google in exchange for  exclusive access to its user base’s activity data. Even while we Mozilla supporters were pitched on the benevolent, non-profit status of the open source Mozilla project, the managers of Mozilla were operating as a for-profit company in partnership with Google. They even had to put off filing their taxes, so they could restructure as a for-profit entity nearly 18 months back, to avoid IRS penalties.

What do you think? Is covert user tracking enough of a benefit for Google to offer this program? Is the knowledge Google gain about the relative usage of these libraries so valuable (e.g. how many sites are loading jQuery vs. how many use Prototype)” What am I missing? Please comment if you know.

Q: Could it be that Google is getting code inserted into the AJAX libraries it is hosting, much like it got access to Mozilla’s userbase’s activity stream?

That would see so evil, since user interface libraries can do just about anything with the page they load in (your page, by the way). They can manipulate the page, or even track mouse movements without waiting for the user to click. Google could know if you hover on ads and don’t click, for example.

I’m not asking for anti-Google tin foil hat conspiracy theories… I just need helpful, honest analysis that will help answer the question – Why is Google hosting the common Javascript libraries (javascript APIs) for free? 


  1. Alex wrote:

    It “loads faster” because JS is compressed and cached, and browsers’ 2x-per-domain concurrent connections limit – so a browser can load files from Google while also loading them from my server, but they might be queued in near-series if they all had to load from my server.

    I suppose Google could make changes to the code but someone would notice eventually..

    Tuesday, March 3, 2009 at 12:52 pm | Permalink
  2. john wrote:

    Thanks Alex.

    Tuesday, March 3, 2009 at 1:03 pm | Permalink
  3. john andrews wrote:

    Brian also notes that G can “trust” the libraries, which is obviously good for them (and can skip them completely in a crawl, so save effort). Good points.

    Tuesday, March 3, 2009 at 1:05 pm | Permalink
  4. sh wrote:

    You are missing the “spying” part. It gathers user data with
    occasional loading…

    Tuesday, March 3, 2009 at 3:07 pm | Permalink
  5. Andrew wrote:

    There is definitely some additional tracking going on. See some details here:

    Tuesday, March 3, 2009 at 3:27 pm | Permalink
  6. Chris Snyder wrote:

    I’ll let Yochum publish his findings re tracking, but the reason I don’t use the Google hosted javascript libraries is simple: I have no reason to trust that they won’t, at some point in the /indefinite/ future, inject their own code into those libs and break my apps.

    You have to admit, even without attributing any malice or power issues to Google, that their central code repository will be an attractive target to someone wishing to cause mayhem on the web.

    As for why they are doing it? It’s a cheap service that makes their own development efforts easier, and they get the bonus of being able to track (with more or less precision depending on the method used to include the libs) who is using what. They can focus their own efforts to provide better hooks and services to the devs who are using the big three libs.

    Tuesday, March 3, 2009 at 3:35 pm | Permalink
  7. James wrote:

    The reason they host them is to help webmasters. Google trys to help webmasters as much as possible, to build their trust and hopefully keep them using their services.

    The reason they are a good thing as a webmaster is that if many sites use these the libraries will get cached in the users browser at some point and then when he goes to another site using the google libraries he doesn’t have to load them up again.

    Wednesday, March 4, 2009 at 10:06 am | Permalink
  8. Ben Lisbakken wrote:

    Hi, my name is Ben Lisbakken and I’m on the AJAX Libraries team.  I see a number of questions here so let me address them.

    – Why does Google host these libraries?
    The AJAX Libraries API came about because our team sat down and brainstormed how we could solve existing problems on the web that can only be solved by large companies such as Google — one of those problems is that the same bits from a few popular libraries are being grabbed millions and millions of times a day and it’s unnecessary.  Google is uniquely positioned to serve large amounts of traffic from around the world at the fastest speeds so we decided that creating this API could help other sites as well as our own.

    – Is Google using the referrer/IP for tracking users?
    No.  The API is not a devious plot to track users. Our intention was to help speed up the web and help with some of the chaos that we see in the wild. There are still plenty of sites that are not setting correct cache headers to minimize latency and don’t have the global deployment to ensure that users visiting from Europe see the same low latencies as those on the west coast of the US.

    With that said, we do have logs of referrers, IPs, and user-agents. There is no user tracking, and these logs are subject to our 9 month anonymization policy (details at Our team uses these logs to understand the performance, adoption, and status of the system. These signals are used by us mainly for capacity planning purposes. Since we launched the API last year, we have expanded some of our operations and grown our capacity. The signals we get from these logs are directly responsible for our ability to meet the needs of the community and help ensure global, low latency access to the system.

    – Why are we hosting SWFObject?
    We host the most popular libraries because the caching benefits are greatest (more sites using them through Google means users are more likely to have it in their cache) and SWFObject is one of these popular libraries.

    Additionally, SWFObject is hosted on our Open Source Code hosting,  It became a very popular library and developers started including the Javascript directly from  Our code hosting servers were meant to host code for development purposes, not as production servers.  We contacted the creators of SWFObject and asked them to direct users to the AJAX Libraries API which has production servers meant to handle the high load.

    – Does Google insert code into the libraries?  Will they?
    Absolutely not.  We refuse to make any changes, trivial or not, to any of the libraries we host.  You can verify this by downloading the libraries from us and the maintainers and do an MD5 checksum on them.

    – What does the /stats request do?
    Because many loads of the libraries are cached, we never see requests for them.  In order to better estimate our traffic, we use this request to inform us what has been loaded. Also, the request happens asynchronously much after the page loads so that we don’t slow down the application performance.  If you don’t want these requests to happen, you can include the libraries directly instead of through the loader.  The direct links are all listed here:

    Sunday, March 8, 2009 at 2:27 am | Permalink
  9. federico wrote:

    @Ben Lisbakken

    Question arose…why your team sat down and brainstormed how you could solve existing problems on the web?

    I mean, important question is not “Why does Google host these libraries?”, instead, why google want to help us? what did they gain?

    As a profit-based company they must get something in exchange. That’s a business golden rule and I dont think google is the exception.

    Sorry to be so distrustful but I just simply don’t get it.

    Wednesday, July 29, 2009 at 9:25 am | Permalink
  10. I cam across this late but I’d like to add my $.02.

    I don’t understand a lot of this discussion considering Google in general. @federico, business does have golden rules and marketing, public perception, and company image are all very high on the golden rule list. I do believe Google does do things “just” for the user without a very short term measurable ($.15 per click) value. But the long term indirect value must be measured.

    It’s very short sighted to think Google would try and “slip one by” it’s users in some of the methods previously posted. It would have detrimental effects to their company. Web developers, the source of their money, would jump ship, FAST. They know we are the ones that use Google products, code Google Adwords for programs and sites, recommend search engines to friends, and generate “buzz.”

    The other more philanthropist reason for doing this is as mentioned the over all load on the internet. As Ben said making a significant contribution to this would require a company the size of Google. The fact that they make so much money means that they can afford to dedicate employees to projects like this. And why not?

    Think of the AJAX API team as an extension of the marketing department with real benefits.

    Tuesday, December 22, 2009 at 6:10 pm | Permalink