Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any problems/disadvantages hosting jQuery at Google?

Tags:

jquery

I heard that some people where having problems accessing their sites which get their jQuery from Google since their corporate firewall didn't like sites getting code from other sites, i.e. cross-site scripting?

Has anyone run into problem such as this?

like image 698
Edward Tanguay Avatar asked Jan 14 '09 13:01

Edward Tanguay


People also ask

What is the advantage of hosting a jQuery using a CDN?

jQuery CDN is a light JavaScript framework that speeds up website development by simplifying event handling, animation, AJAX interactions, and HTML page traversal. The jQuery UI CDN makes HTML client-side scripting easier, making developing Web 2.0 applications easier.

Why use jQuery?

The purpose of jQuery is to make it much easier to use JavaScript on your website. jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code.


2 Answers

One problem is that Google's server can and do go down at the worst possible times. In my answer to the question "What was your most uncomfortable programming experience?", I answered:

I was demonstrating my team's new web application to a group of potential users. I took a few minutes to talk about all the cool stuff the Google Visualization API can do, since we were using it heavily in our application. To demonstrate, I decided to graph a few sets of data we have collected previously. It was intended to convey the message: "Look how easy it is! Regular people can make good looking graphs using our product."

As luck would have it, the Google servers that hosted the Javascript files necessary to use the Visualization API decided to stop working midway during my presentation. I sat in the chair, staring at the screen, mumbling to myself "but... but they're Google... their servers can't go down". The team tried to laugh it off, but everyone realized at that moment how dangerous it can be to rely on any third party (even one as big as Google) when it really counts.

I know it seems unlikely, but unless you really have no other choice, I would recommend against hosting critical files on third-party servers, even if they are Google's servers. Having customers complain about an outage is bad. Having customers complain about an outage that isn't your fault and that you can't solve is even worse.

like image 131
William Brendel Avatar answered Nov 15 '22 20:11

William Brendel


I presume by hosting at Google you mean the AJAX Libraries API? The advantages that I can see are:

  1. You'll save bandwidth on your site since the JS is coming from Google's CDN
  2. You may see better responsiveness and speed, since the content is coming from Google's distributed CDN, instead of your servers.
  3. If users have previously visited another site that uses Google to host its JS libraries, the user's browser may already have them cached.
  4. Google apply the latest bug fixes and security patches for the version of the library that you're running. Contrary to what others have claimed, they do not automatically upgrade you to the latest version. E.g. if you specify you want Mootools 1.11, you won't be given 1.2 or any later version unless you specifically change your script include call to request it. But they will apply fixes specific to that version.

And the disadvantages:

  1. Like you mention, some more zealous security tools and products may take issue with including scripts from a different host. I don't know how widespread a problem this is, but it's worth investigation.
  2. It potentially adds another DNS lookup to the page load.
  3. Google have committed to host each version of the libraries "indefinitely", and you'd hope they mean it. But fortunes and policies change, and if the hosting service is discontinued, you might find yourself having to revisit a number of sites to fix their JS.
  4. You're reliant on a third-party to host some of your content. Obviously you'd expect Google's uptimes to be pretty good, but if they do have problems, you might have to explain to your customer why their site isn't working just because Google is having network problems.
  5. Google host the full version of each library, but some like Mootools let you create custom versions containing just the components you need. So the Google version might be more full-fat than you need.
  6. You had no ability to customise or change the library. Making downstream changes to a library is a hairy proposition, but if you're in a jam it might be the easiest option. Having the library hosted externally adds an extra complication, as you'll have to switch to an internal copy.
  7. Bug fixes do get applied for your chosen version, so if you're somehow dependent on the buggy behaviour this may cause problems. Presumably the library authors will be very careful about potential breaking changes, but it's Murphy's law that problems will arise somewhere.
like image 35
Jon Rimmer Avatar answered Nov 15 '22 18:11

Jon Rimmer