views:

67

answers:

3

JS library like JQuery can be linked directly from other site (e.g. google). Usually I use

<script type="text/javascript" src="/js/jQuery.min.js"></script>

But I can use

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;

or similar.

I like to take full control over my site, so I use the first way. But using google or other host has some advantage (i.e. decreased latency, increased parallelism, better caching). Both have advantage and disadvantage. What should I use? What you use and why?

Please let me know your opinion.

Thank you

+1  A: 

I use Google where possible for performance reasons, but I also check in a local copy in case I need to work on the site when I am offline, e.g., on an airplane, or at a remote location with no internet access.

RedFilter
+4  A: 

I think that it depends on the audience of your website.

If your site is public facing and people are going to be accessing it primarily or exclusively from the internet then you are going to benefit from lower bandwidth utilization, faster responses and caching benefits since the likelihood of the file having been previously referenced and loaded from another site is high.

If your site is internal for an intranet you may run into issues of people do not have internet access but you're also going to be wasting bandwidth since you're sending everyone out over the internet to fetch a file you could host locally.

CptSkippy
But if they ever fetched it from google then they do not need to do it again. They do not need to fetch while they are surfing my site.
Sadi
fetching a javascript file is pretty painless for a decent connection, as long as you aren't pulling down large numbers of files at once.
David
A: 

Don't forget that if you use a copy from google (or whoever), you have to guard against the possibility that they might move or change the file, or that they're server might be down.

If your site needs a specific javascript library, then you should download it and serve it up yourself. If your income depends on that file, the last thing you want is to rely on another site to provide it.

David
I agree, That's why I do not like to use third party to host my file (for free).
Sadi