graphicdivine
graphicdivine

Reputation: 11211

Link to external source or store locally

When using third-party libraries such as jquery, yui-reset, swfobject and so on, do you link to the hosted versions, or download and host your own versions?

Pros and cons either way?

Upvotes: 0

Views: 164

Answers (4)

zaf
zaf

Reputation: 23244

For production use hosted.

For development use local because if you're offline then your dev site is broke.

Upvotes: 1

Graza
Graza

Reputation: 5050

Hosted versions are apparently the way to go. For three main reasons (edit: I've added a fourth reason, but it's sort of a moot point):

  1. Google/jQuery/etc servers are likely to be faster than your own
  2. A lot of these servers use content distribution so it will be served from a server geographically close to the requester
  3. If every site used the hosted versions, users are more likely to have the files cached in their browsers, so a trip to the server might not even be necessary
  4. They are possibly more reliable than your own server (however if your own server goes down, this point is moot, as you probably won't be able to serve the main page, so there won't be a request to the js file anyway)

Cons would be

  1. You have no control over the uptime/reliability of the servers (though they are more likely more reliable than your own)
  2. Cannot make any custom mods/patches to these files (though most good frameworks allow you to extend them without needing to modify the original code)
  3. If the hosted file does not allow you to specify the version as part of the filename (eg "jquery-1.3.2.js" rather than "jquery.js"), you probably don't want to use the hosted version, as any updates could possibly break your code

I would say the pros generally outweigh the cons.

Upvotes: 5

Romain Hippeau
Romain Hippeau

Reputation: 24375

These are all javascript libraries - You want to put a copy of it on your own server. If you somehow use a different version then you would not have tested against the newer version and it might break your code.

Upvotes: 2

Kyle
Kyle

Reputation: 67194

I always download and host them locally, just because I'm worried about their server downtime, there's no real guarantee that their servers will be up for the rest of time. There is usually a note in the script about who it belongs to anyway.

I guess the only con would be if the person who made the script wouldn't actually want it downloaded.. But I don't see that ever happening.

Plus the requests times are much faster, instead of requesting a script hosted at google, just request it on your own server.

Upvotes: 1

Related Questions