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?
.css
and if the same file is included again..
.css
I know the browser will cache and doesn't make a subsequent request, but what other performance issues can it cause?
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./sample.css
and if the same file is included again..
http://example./sample.css
I know the browser will cache and doesn't make a subsequent request, but what other performance issues can it cause?
Share Improve this question edited Nov 30, 2011 at 0:50 Muhd 25.7k22 gold badges65 silver badges79 bronze badges asked Apr 23, 2011 at 19:59 kobekobe 15.8k15 gold badges65 silver badges93 bronze badges 2- 2 How about "just don't do it?" – Matt Ball Commented Apr 23, 2011 at 20:04
- 1 @Matt ball , yeah , the website already has this problem , i just want to go through the plete website and clean up , but i want to know what is the really issue in this duplicate includes. The website is pretty plex. – kobe Commented Apr 23, 2011 at 20:13
2 Answers
Reset to default 6Duplicate 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 putation will be longer too.