Referencing external javascript vs. hosting my own copy

Posted by Mr. Jefferson on Programmers See other posts from Programmers or by Mr. Jefferson
Published on 2012-03-12T17:13:17Z Indexed on 2012/06/12 22:48 UTC
Read the original article Hit count: 236

Filed under:
|
|

Say I have a web app that uses jQuery. Is it better practice to host the necessary javascript files on my own servers along with my website files, or to reference them on jQuery's CDN (example: http://code.jquery.com/jquery-1.7.1.min.js)?

I can see pros for both sides:

  • If it's on my servers, that's one less external dependency; if jQuery went down or changed their hosting structure or something like that, then my app breaks. But I feel like that won't happen often; there must be lots of small-time sites doing this, and the jQuery team will want to avoid breaking them.
  • If it's on my servers, that's one less external reference that someone could call a security issue
  • If it's referenced externally, then I don't have to worry about the bandwidth to serve the files (though I know it's not that much).
  • If it's referenced externally and I'm deploying this web site to lots of servers that need to have their own copies of all the files, then it's one less file I have to remember to copy/update.

© Programmers or respective owner

Related posts about web-development

Related posts about JavaScript