开发者

Duplicate javascript and css includes

开发者 https://www.devze.com 2023-02-28 02:28 出处:网络
I have a question regarding the javascript includes and css includes. What happens if we included the same css or javascript files two times by different 开发者_运维百科developers?

I have a question regarding the javascript includes and css includes. What happens if we included the same css or javascript files two times by different 开发者_运维百科developers?

http://example.com/sample.css

and if the same file is included again..

http://example.com/sample.css

I know the browser will cache and doesn't make a subsequent request, but what other performance issues can it cause?


Duplicate JavaScript and CSS files hurt performance by creating unnecessary HTTP requests (IE only) and wasted JavaScript execution (IE and Firefox).

In IE, if an external script is included twice and is not cacheable, it generates two HTTP requests during page loading. Even if the script is cacheable, extra HTTP requests occur when the user reloads the page.

In both IE and Firefox, duplicate JavaScript scripts cause wasted time evaluating the same scripts more than once.

This redundant script execution happens regardless of whether the script is cacheable.


For more information about how to make web site load faster, refer to this really good article.

I have pasted the info about duplicate JavaScript and CSS, here in the answer above.


For CSS, the duplication will mean that twice the selector matching will have to be done, and for rules that match they will match twice, so the time to do style computation will be longer too.

0

精彩评论

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