Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to use code from code.jquery.com for long-term application?

Tags:

jquery

ajax

I am using Ajax / jquery on a webpage i am designing... in order for it to function, i include (at the top of my page) the javascript at: http://code.jquery.com/jquery-1.4.4.js

This works great and all, but i have a fear that 1) the code might get changed without me knowing, then i encounter problems and try to debug for days / hours before finding that the code at this site changed

2) the website is no longer used / specific code no longer hosted years from now

So would it be safer to save that javascript file onto my server, and access it from there?

like image 904
Adam Avatar asked Jan 20 '11 15:01

Adam


2 Answers

You should use either a Microsoft or Google CDN. It will be much faster, it will be cached for a lot of your users and it's guaranteed to be there, as opposed to the jQuery link you include.

like image 102
Marek Karbarz Avatar answered Nov 15 '22 06:11

Marek Karbarz


http://code.jquery.com is jQuery's CDN (provided by Media Temple). The code at http://code.jquery.com/jquery-1.4.4.js will never change; jQuery will release a new version (which will be at a different URL), if anything needs to change (which happens all the time; version 1.5b was released today).

The jQuery guys know what they're doing, and they setup a CDN so people can easily link to jQuery. They're just as (un)likely to bring down the CDN as Google and Microsoft are at bringing theirs down.

See http://docs.jquery.com/Downloading_jQuery for more information.

Having said that, it would seem the Google hosted version (http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js), is referenced more in websites; this leads to a small performance advantage as far as your users are concerned, as the file has more chance of being cached.

like image 45
Matt Avatar answered Nov 15 '22 04:11

Matt