Where should the JS library (host) be located?

A JS library such as jQuery can be directly linked to another site (e.g. google). I usually 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"></script> 

or similar.

I like to completely control my site, so I use the first method. But using google or another host has some advantage (i.e., reduced latency, increased parallelism, better caching). Both have an advantage and a disadvantage. What should i use? What do you use and why?

Please let me know your opinion.

thanks

+4
source share
3 answers

I think it depends on the audience of your site.

If your site is open to the public, and people will access it primarily or exclusively from the Internet, then you will benefit from the use of lower bandwidth, faster responses, and the benefits of caching, as it is likely that the file was previously specified and loading from another site is high.

If your site is internal to the intranet, you may run into problems of people who do not have access to the Internet, but you will also waste bandwidth as you send everyone over the Internet to get a file that you could host locally .

+5
source

I use Google, where it is possible for performance reasons, but I also check the local copy if I need to work on the site when I'm online, for example, on an airplane or in a remote place without Internet access.

+1
source

Remember that if you use a copy from Google (or anyone else), you must be protected from the possibility that they may move or modify the file, or that they may not be available.

If your site needs a specific javascript library, you must download it and maintain it yourself. If your income depends on this file, the last thing you want is to rely on another site to provide it.

0
source

All Articles