D
D
Denis2016-02-08 10:40:17
Frontend
Denis, 2016-02-08 10:40:17

Combining CSS/JS into one file?

Is it correct to merge CSS/JS files into one (*css/*js)?

Let's say css is included in the project:

1. Bootstrap.css
2. Font Awesome.css
3. Own styles

AND JavaScript:

1. JQuery.js
2. Bootstrap.js
3. Own scripts

Then all this is combined into one style.css file and plugin .js with subsequent compression and connects to the site.
Is mixing framework, icons, custom styles/scripts in my example acceptable? Or is it better to connect separately?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
B
bernex, 2016-02-08
@valetu

As I understand it, css + js is supposed to be injected into the resulting html.
I don't see the point in this. Compressing and concatenating files is useful for reducing the number of requests and reducing the size. And it remains possible to take it from the cache, upon repeated access.
If you have it on all pages in the body of the page, then this volume will be loaded every time.
If you have a single-page application, then in fact you can do it that way, but why I don’t find any pluses.
Now there is http2/spdy and you can even relax a little.
And so in general, gulp and compression are separately css vendors and their own, js vendors and their own.
You collect your own when you edit something, vendor files when libraries are updated.
Some libraries (jQuery) are recommended to be taken from common CDNs, there is a high probability that they will already be in the cache and, in fact, everything will be instantaneous.

W
Wheelie, 2016-02-08
@Wheelie

gulpjs.com

Z
Zhainar, 2016-02-08
@zhainar

Separately.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question