H
H
HoHsi2015-12-08 16:36:31
Browsers
HoHsi, 2015-12-08 16:36:31

Should I concatenate JS/CSS files?

Good evening!
Should I use JS/CSS file concatenation? Personally, I now see a number of advantages and disadvantages:
Advantages:
* Nginx only serves 2 static files.
* You can use the `async` attribute since everything is in the same file.
* Nothing will be lost.
* Gzip will compress better (maybe).
Disadvantages:
* Versioning. Even with the slightest change in the script, the client will have to download everything again.
* File size. Let's say there is JQ2 or Angular, then the concatenated file will weigh ~100 - 200kb. (Bad for mobile phones).
Have you faced such questions, and in what favor did you choose?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Lebedev, 2015-12-08
@swanrnd

We merge.
At me it is broken so:
- libraries and a kernel which seldom change.
- frequently changed part.
In general, 3-4 files are much better than 20.
In general, it's good when there are no more than 6 external files.
This includes both favicon and pictures.

B
biostrain, 2015-12-08
@biostrain

I personally merge files. And you correctly described the benefits.
And about the shortcomings .. Scripts do not change so often, the client will not even notice. And for mobile phones, you can give a "lite" version.

S
sim3x, 2015-12-08
@sim3x

caniuse.com/#feat=http2
As usual - we look at our user, then at the user who brings us (the client) income and adapt to it
From the point of view of front-end software and web servers - everything has already been done

Nginx gives only 2 static files.
do you use pictures?
You can use the `async` attribute since everything is in the same file.
it is already used if the browser can
Nothing will be lost.
rave
Gzip will compress better (perhaps).
definitely better
Versioning. Even with the slightest change in the script, the client will have to download everything again.
if the client has 90% of new users, then somehow purple
File size. Let's say there is JQ2 or Angular, then the concatenated file will weigh ~100 - 200kb. (Bad for mobile phones).
who is bad, and who walks through 4g or wifi

Similar questions
K
kocherman2012-07-25 17:44:39
Is it possible to use such construction in html