I suppose I ask that if grouping JavaScript is considered good practice, why do not more sites put JavaScript and CSS directly in the same HTML document?
why do not more sites put JavaScript and CSS directly into one HTML document.
Individual file caching.
External files have the advantage of caching. Since scripts and styles rarely change (static) and / or are shared between pages, it’s better to simply separate them from the page, making the page easier.
, 500 . JS CSS, 5kb , JS CSS 495 - 495 2 HTTP-.
JS CSS , , , . , .
WordPress. , . , , , .
- , , , , , , .
, , , .
, , , , .
script, , , , , :
script, , .
, , .
They separated them so that multiple web pages could use the same file. When you change a single file, you can also refresh multiple pages. In addition, a large HTML file will be uploaded for a long time.