22

I do not find it cozy to leave footprints on Facebook, Google and alike upon every single step I do on the Internet. For this purpose I use a script blocker. Now I found that Stack Overflow does not allow login without allowing it to use ajax.googleapis.com.

Why does Stack Overflow require JavaScript from Google in order to work? Which information is forwarded to Google upon acting on Stack Overflow?

2

2 Answers 2

29

We use jQuery - a very popular JavaScript library - at Stack Exchange.

For technical reasons, we use the Google CDN for the jQuery files (a CDN is a Content Delivery Network - a bit of technology that makes distributing things like images and JavaScript libraries across the world faster) - that's what is hosted on ajax.googleapis.com. This is something many many sites do and as result many people will already have this library on their computer.

You will note that the full URL of the blocked request is:

http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js

That is the jQuery library we use.

Much of our JavaScript code leverages jQuery, so if it is not loaded, things do not work.

11
  • 5
    Clarified thanks. With all due respect to the big ones, and as great as Google's offers of cdn, analytics and so (dns) are, I think it is time to consider passing a bit less requests to them and use alternatives like //code.jquery.com/jquery-1.10.2.min.js .
    – citykid
    Jan 12, 2014 at 13:23
  • 7
    @citykid the resource is heavily cached, though, as waiwai933 says, so this isn't really a way for them to track your internet usage.
    – Pekka
    Jan 12, 2014 at 14:58
  • @citykid I would bet that the Google CDN has orders of magnitude more access points than jQuery's does, so the decision has to do with scale more than some nefarious plot to track your SO usage...
    – MattDMo
    Jan 12, 2014 at 15:50
  • comments agreed.
    – citykid
    Jan 12, 2014 at 16:18
  • 2
    @AlienArrays only if Google will start hiring unicorns. Jan 12, 2014 at 20:52
  • There's always a chance that Google, or Microsoft, or Warren Buffet, will but Stack Exchange Inc. I will, in that event, celebrate the good fortune of its shareholders and employees.
    – Rosinante
    Jan 12, 2014 at 22:21
  • @ShadowWizard lifehacker.com.au/2013/09/…
    – JDB
    Jan 13, 2014 at 0:24
  • @JDB wow, guess they're really going to buy Stack Exchange then! ;) Jan 13, 2014 at 7:47
  • 2
    Given Google's resources, use Google CDN for jQuery worldwide delivery is a good choice, but, almost all Google based services is blocked in China mainland, so nothing on Google's CDN can get in China, have Stack Overflow consider another option to delivery jQuery script to the 1.4 Billion population. And I really don't understand why a 91.7Kb script require external help to delivery? Can't Stack Overflow just to it by itself?
    – Albert
    Dec 6, 2015 at 9:01
  • 2
    Google sets a max-age of 365 days with a 30 day stale-while-revalidate cache on jQuery. Stack Exchange could easily do the same. The performance difference between hosting this on Google's CDN vs. internally on SE is minimal and would only be realized by users who either clear their cache daily or never visit the site. For users who clear their cache often, they would welcome this change as it is one less signal to google. I personally use Decentraleyes to block google CDN. It would also help Chinese users, and be one less DNS query & server that can have outages. Aug 16, 2017 at 17:51
  • @Pëkka Your comment is misleading. Browsers will still have to check if the resource was modified with the server. Aug 7, 2019 at 6:19
21

There is a very popular Javascript library known as jQuery. Google hosts a free CDN for a number of Javascript libraries including jQuery.

As a lot of websites use Google's CDN for jQuery, a large number of visitors to Stack Exchange will already have it cached and not need to reload it, thus resulting in a faster user experience. In contrast, if SE were to personally serve jQuery on their CDN, every first-time visitor to Stack Exchange would have to retrieve it.

The only information Google gets from you when you fetch jQuery is basic information that your browser sends to every website you visit. Because Google's CDN is not hosted on google.com, Google's standard cookies are not sent, and as far as I can tell, Google does not set cookies on googleapis.com, partly because that would only decrease the efficiency of a CDN.

For example, my browser sent this

GET /ajax/libs/jquery/1.10.2/jquery.min.js HTTP/1.1
Host: ajax.googleapis.com
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
DNT: 1
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
If-Modified-Since: Tue, 09 Jul 2013 11:31:25 GMT
7
  • no need for the entrance sarcasm, but thx for the very clear and detailed answer.
    – citykid
    Jan 12, 2014 at 13:25
  • 20
    I don't think he was being sarcastic. (Not everyone knows what jQuery is.)
    – Pekka
    Jan 12, 2014 at 14:57
  • 6
    @Pëkka What's jQuery? Should I drop what I'm doing and try it?
    – Cole Tobin
    Jan 12, 2014 at 18:11
  • 3
    @Cole you should indeed.
    – Pekka
    Jan 12, 2014 at 18:11
  • 4
    Not setting cookies is by itself no guarantee that no basic tracking can be done. Many browsers send a If-Modified-Since (based on the Last-Modified date) or If-None-Match (based on the ETag) request when the user simply hits refresh. (Even for a regular refresh; don't ask me why. It seems Chrome has recently stopped doing so.) But indeed, Google's CDN does not return any specific information that a browser can accidentally emit when asking if a cached resource is still valid.
    – Arjan
    Jan 12, 2014 at 18:36
  • 5
    And what about the referer? Jan 12, 2014 at 22:19
  • 2
    Exactly: the referer is sent, surprised why it is not included above. on my system for instance: Referer: stackoverflow.com even including the topic like: Referer: stackoverflow.com/questions/tagged/javascript
    – citykid
    Mar 23, 2014 at 9:10

Not the answer you're looking for? Browse other questions tagged .