i don't get it

Story: Sites knocked offline by OpenDNS freeze on GoogleTotal Replies: 12
Author Content
mbaehrlxer

Jan 05, 2012
11:22 PM EDT
why would i ever want to link to a javascript library that my site depends on, from some 3-rd party host? seems like a recipe for disaster to me. just to save a few cents in download cost?

this example here is just one thing that can go wrong.

someone please tell me that i am wrong and that there are very good reasons for doing this. otherwise i'd go as far as saying that the sites that follow this practice deserve what they got.

greetings, eMBee.
tracyanne

Jan 05, 2012
11:29 PM EDT
Just do what I do download the Javascript library and serve it from the client's own website. Saves on having to rely on third parties.
gus3

Jan 05, 2012
11:47 PM EDT
JQuery via Google means updates and fixes to JQuery are published without site admin intervention. Same thing with Yahoo API's.

(Not worth it, IMNSHO.)
tracyanne

Jan 06, 2012
12:01 AM EDT
When we can actually rely on the web, and, what with the US passing special interest bills like SOPA, I don't see that day coming anytime soon, then yes, link to 3rd party websites for important functionality in one's client's Websites, by all means, until then the reliability of my client's website comes before some marginal amount of extra convenience.
mbaehrlxer

Jan 06, 2012
3:54 AM EDT
tracyanne: until i read this article i had not even considered not serving from the client's own website. it's kinda like not providing a bathroom in my restaurant because customers can go to the neighbors restaurant to use the bathroom instead...

gus3: not only not worth it, a bad idea too. what if the update breaks something? also, in the linked article about a workaround it shows that the link is made to a versioned path, so upgrades would not be covered there.

greetings, eMBee.
tracyanne

Jan 06, 2012
3:58 AM EDT
@embee, you'd be surprised how many corporate websites link to 3rd party providers... then again, maybe not.
jacog

Jan 06, 2012
4:15 AM EDT
Having jQuery linked directly on Google in order to escape the hassle of updating it actually creates potentially more hassle. Mainly because you might be running several plugins, some of which will rely on a particular version of jQuery - then one day, unbeknownst to you, they update jQuery and half your plugins break.

What mb/ta said. :)
Khamul

Jan 06, 2012
4:18 AM EDT
There's a few reasons:

1) To save on your site's bandwidth. A ~70k file multiplied by thousands of visitors a day adds up to a fair bit of bandwidth.

2) More importantly, to improve your site's loading speed. If a user visits 20 different sites all using the latest jQuery, but which self-host it, he'll have to download that exact same library 20 times. But if those sites all point to Google, then that user only downloads the library once, and stores it in the browser's cache for subsequent sites which also point to the same place.

Finally, you don't have to depend on Google. Use the following code in your header:

  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
  <script type="text/javascript">
    if(typeof jQuery === 'undefined') {
        document.write(unescape('%3Cscript type="text/javascript" src="js/jquery-1.4.4.min.js" %3E%3C/script%3E'));
    }
  </script> <!--fall back to local copy of jquery-->


This will load the library from Google, but if Google fails for some reason, it'll fall back to your local copy.
tracyanne

Jan 06, 2012
5:06 AM EDT
The other reason for not using a third party is security, and no Khamul I don't see any reason to trust Google such that I'm going to plug in a script from them into my client's secure pages. I'll go with a minor speed hit, and I don't think that 70k is such a big deal when compared to the size of images and other media.
jacog

Jan 06, 2012
5:40 AM EDT
Yarrp, I think the days of tiny little sub-50Kb pages are long gone.
mbaehrlxer

Jan 06, 2012
6:17 AM EDT
tracyanne: i am not surprised at linking to 3rd party providers for site specific functionality, some site's like button, message feeds and all that stuff. and i would also not be surprised for some to link to a version provided by the developers of a library, like you use some google api by linking to a library file on googles site. but there is no indication on the jquery site to do so, but only instructions on how to download your customized version of jquery. that means whoever links to somewhere else must have specifically thought about it being a better alternative.

greetings, eMBee.
Khamul

Jan 06, 2012
10:59 PM EDT
@tracyanne: It depends on your needs; if you're doing something high-security, then obviously linking to Google stuff isn't a great idea. If you're just hosting a blog, then what's the big deal?
tracyanne

Jan 07, 2012
12:53 AM EDT
Quoting:if you're doing something high-security, ...


Well my client certainly believes it is, as it includes credit card payments pages, and his web interface to administer the site.

Quoting:If you're just hosting a blog, then what's the big deal?


If it was my blog, the less access I give to Google the better.

Posting in this forum is limited to members of the group: [ForumMods, SITEADMINS, MEMBERS.]

Becoming a member of LXer is easy and free. Join Us!