开发者

Loading jQuery and related stuff from Google

开发者 https://www.devze.com 2023-01-25 00:45 出处:网络
Is it really faster than loading it from your host? Because when you open a website which loads stuff from other sites, the browser has to make new connections. Wouldn\'t it be faster to load all the

Is it really faster than loading it from your host?

Because when you open a website which loads stuff from other sites, the browser has to make new connections. Wouldn't it be faster to load all the stuff from the site that the browser is alre开发者_如何学Cady connected to?


When your browser downloads html/css/js/img files from a site it can only load a few at a time (some two, some up to 8, I believe). This is per domain though.

By using a google cdn you have an additional simultaneous download, a greater chance of the file already being cached, plus they are using a server closer to the end user.

Personally, our load times have improved greatly using the google cdn of jquery.


I am personally a fan of loading it from google because if the user has visited another site that used the same javascript from google then it has already been cached!

The other advantage is that many browsers load assets from different domains simultaneously. So if some are loading from your host then another one can be loaded from google for better performance.


I wouldn't bet on your servers being faster than Google's, or having better caching. Besides, the more work you make your servers do ... the more work you make your servers do. How is that faster? Anyway, on subsequent visits the jQuery most likely winds up in the browser cache anyway.


it would be if the browser hadn't likely already cached the version from google since it already loaded it while visiting a site that used the google link (like stack overflow)


The chances are decent that users have already cached Google's JS files in their browser. If you reference the same file, the browser won't even have to download it again.

0

精彩评论

暂无评论...
验证码 换一张
取 消