1

Regarding the fact that C in CSS stands for Cascade, so generally speaking rules described in one file can modify/subsitute rules in other files, can we claim that all project css files should be concatenated to a single file in most cases.

Because browser still won't get all style computed till all rules will be taken into consideration.

In other words, is there any sense in parallelizing download of styles for web project. What will be the rule of thumb to decide whether css file should be splitted into multiple or vice versa?

May be, say, we can claim that there are "crucial" css properties - like dimensions, paddings and margins - and less crucial - like colors, transitions etc.? And that less crucial styles could be downloaded as a separate resource?

2 Answers 2

1

One reason to keep multiple CSS files in the development environment is that one part of the style is common for all (or many) web pages and other parts differ per web page. For example, an application may support multiple brands. One css file contains the styles common for all brands and there are brand-specific styles.

You could also have separate style sheets per logical unit, e.g. a style sheet for styling customer data, one for styling an image gallery etc. When multiple developers need to adapt the styles simultaneously, the chance that they need the same file (and thus need to merge often) decreases.

However, in most cases, style sheets are concatenated and minified in the production environment.

One reason why it may be good to keep the files separate in the production environment is that the css file that is reused on multiple pages can be cached. When loading a page, only the page-specific style sheet needs to be downloaded. You have one more file to download, but less data to download in total. In many cases, the size of a style sheet is relatively small and the benefit of a cached style sheet is too small to justify the extra request.

0

As with many projects - management. I have a project where I maintain 5 Less stylesheets but are compiled into a single file.

This makes it easy to go to where I need to go but only need to include a single file for the project. Minifying it further shrinks the file.

I do have other CSS files for third party scripts and whatnot, but for the site its how I have been managing it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.