There are several reasons:
- Browsers usually have limits on the number of HTTP requests that they can make to this site at the same time (due to politeness, more than due to some kind of true technical restriction), and you do not need Script.Js and Z scripts. css supporting scriptA.js and A.css;
- Each individual HTTP request has overhead in latency and throughput, even if it is a "conditional GET", which leads to the answer "304 - not changed";
- Caches become invalid from time to time. In HTTP, the exact expiration time is usually set by the server in the headers of the HTTP response. The problem is that the server never knows exactly how long it will be until the update is published, so it constantly hedges its bids and gives a “fairly short” expiration date. (Using unique generated names for resources included in the HTML file is one way to evade this bullet ... you only need to check the attached HTML page.
There is a small reason to have 2 scripts:
- You may have one script that runs ASAP, and a large script loads.
But yes, it's all about the speed perceived by the end user ... especially when loading the first page when you are trying to get their attention.
source share