Does it matter if one uses multiple css files to break the site down or is it better to use just one or two css files?

DG

Comments

vm’s picture

you can use as many css files as you want and than use css aggreation to combine them in to one file. Making multiple calls to the server to get css files can slow things down some and some browsers only allow a certain amount of css files to be called per page load from what I understand.

Zohar.Babin’s picture

AFAIK, having one CSS is better since the browser doesn't need to load many files.
loading of X CSS files takes longer than 1 file since headers/requests/responses are accumulated to the total file sizes.

assume that each file is 1kb which takes (for the example) 1sec, and each request takes 0.1sec, and you have 10 files of 1kb:

10*1kb = 10kb = 10sec
0.1sec * 10 files = 1sec
10sec (of data) + 1 sec (requests) = 11 sec

but in one file of 10kb:

10kb = 10sec
0.1sec * 1 file = 0.1sec
10sec (data) + 0.1sec (req) = 10.1 sec

As VeryMisunderstood commented - you can use CSS aggregation to serve 1 file although you are developing with multiple.

Gonen
Kaltura - Open Source Video Platform

yelvington’s picture

In order to take advantage of Drupal's ability to aggregate and compress CSS files, you have to use Drupal's API to construct CSS references. Don't hardcode them.

http://api.drupal.org/api/function/drupal_add_css/6

Leave CSS aggregation turned off while you are developing and testing. Enable it when you're done.