If grouping the front-end code helps reduce the number of requests, why not more websites written on one html document?

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?

+5
source share
3 answers

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. , . , , , .

  • - , , , , , , .

  • HTML CSS JS. , , .
+3

, , , .

, , , , .

script, , , , , :

  • script, , .

  • , , .

+3

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.

+2
source

All Articles