6

Would it be wise to combine all CSS into a single file? Would there be any performance increase. I have to assume that an HTTP request is made to get each file on initial page load, and reducing those requests would seem to make sense.

Are there any reasons NOT to combine all css into a single file?(such as maintainability or other performance issue)

5 Answers 5

5

Merging all of your css files into one will absolutely gain performance. Whether that performance is noticeable depends on your load, number of requests etc. For the average blog, this will have close to zero impact.

Read Best practices for speeding up your web site at Yahoo! Developer. It'll explain things way better than i can.

As you say, a reason not to merge css files is for maintainability. However, there are many tools out there which automatically merge and minify your css files into one.

You should check out YUI Compressor, this will help you with merging and minifing your css files.

Sign up to request clarification or add additional context in comments.

Comments

1

Would it be wise to combine all CSS into a single file? Would there be any performance increase. I have to assume that an HTTP request is made to get each file on initial page load, and reducing those requests would seem to make sense.

Yes, but make the combination at build or runtime and don't try to maintain a single file if you started with multiple ones.

In addition to the number of HTTP requests it is also important to set the right expiration headers in the response.

Are there any reasons NOT to combine all css into a single file?(such as maintainability or other performance issue)

It is not necessary to maintain a single file, but good to serve a single file, because CSS data is anyway merged.

The YUI Compressor is a good tool for JavaScript and CSS minification.

Comments

0

Would it be wise to combine all CSS into a single file? Would there be any performance increase. I have to assume that an HTTP request is made to get each file on initial page load, and reducing those requests would seem to make sense.

Yes, yes, yes.

Are there any reasons NOT to combine all css into a single file?

No

(such as maintainability

Combine them at build time and not at development time an there won't be a maintainability problem.

Comments

0

When not all page need all the css then splitting it in multiple files might be faster.

Maintainability becomes an issue if the CSS file gets really huge, when different teams need to coordinate their work on it.

Comments

0

There might be another reason, to NOT combine files:

If the combined stylesheet file is getting too large, Internet Explorer 9 will ignore some of the styles..

See: IE 9 ignoring CSS rules

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.