views:

36

answers:

3

so im trying to include this file for an application

http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js

would including it as this url slow the load time of my site when using an application that requires it?

as opposed to downloading this file and including it locally

+1  A: 

I would think about positive points which over-weigh the negative ones when using google CDN. You might want to read:

Sarfraz
A: 

For the first time, yes. After that, as long as the file has not changed, the browser should cache it, so the load time would not be very high.

Anyway your site (with all its images and javascript files) should load, and this will also take some time the first time. The overhead (on top of this) caused by an external hosted script should not be very high.

Whether you want to use a local version depends on your requirement as well as the purpose of the js file.

jquery.js can be downloaded and used from your server, but, for instance, it does not make much sense to have google analytics scrips locally.

Note: You might see the delay during development because all other files load from the same (local) network, and google hosted scripts load from the internet. (I mention this because someone in my previous project panicked that "google is slow" during a similar scenario. We were using google anayltics scripts)

Nivas
I can correct myself if I am wrong, if the -1 can be explained
Nivas
+1  A: 

Quite the opposite, Google's global network of CDN edge servers is almost certain to give you faster average response times even on the first request.

However, you should never use the "latest" URL like that. In order to reliably start serving newer versions when the time comes, the "latest" URL must respond with a very short expires header, which makes return visits even slower than hosting it on your own server.

The full version URL (e.g. http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js) is served with a +1 year expires header. Always use a fully specified version. Make sure to also do that for initial major version revs, like 1.5.0 instead of 1.5.

Dave Ward
thanks, that makes a lot of sense!
Gazow