Combining all js files into one package and the same with css files

I understand that one of the advantages of combining is the reduction in the number of requests to the server. So, why not merge all js files into one, and all cs files into one? Are there any flaws in this approach?

+4
source share
3 answers

The main drawback of this approach is that the browser must download your entire javascript file before it can start executing any of them. Most likely, this will slow down the work, but there are some framework / tools that do this only for optimization. This can help with a bunch of small files to overcome http overhead.

In addition, if you change any of the files in the kit, you must invalidate the cache and provide the client with a completely new (large) package to download and cache again.

However, as this link explains , such approaches may not be practical when http 2.0 is core. And, apparently, there is a bandwidth threshold in which returns are reduced as speed and latency come into play.

+1

, 2 3 javascripts

javascript 1 2 - 1kb

javascript 3 - 1mb

Page 1 javascript 1 javascript 2

Page 2 javascript 1 javascript 3

,

+2

If you have only one file, you cannot use parallel / parallel browser downloads.

0
source

Source: https://habr.com/ru/post/1528826/


All Articles