Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.5a is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorczheng
    • CommentTimeJan 17th 2006
     permalink
    Hey folks...

    Just a quick question. What do folks consider to be an acceptable file size range for CSS files? Just curious because I'm using a CMS and it tends to lead to a somewhat more bloated stylesheet. I'm working to clean it up and just wanted to get a target. Right now it's about 11k but I'm still working on it.

    I asked on the #css channel on Freenode, but some holier-than-thou CSS snob simply said: "If you're worried about file size, you're clearly doing something wrong."
  1.  permalink
    11K is on the large side, but it depends on how you're using it. A site I recently developed is pushing that size for CSS. A web speed report gives me the following error:

    CSS_SIZE - Warning! The total size of your external CSS is 10149 bytes, which is over 8K. Consider optimizing your CSS for size by eliminating whitespace, using shorthand notation, and combining multiple CSS files where appropriate.

    Take that for what it's worth.
  2.  permalink
    < 4 is optimal, however, as high as 8 is acceptable.

    Anything greater than 10 and it's just too large.
    • CommentAuthorczheng
    • CommentTimeJan 17th 2006
     permalink
    cool, thanks guys. I've got it down to 10k so far. i'll set my sights on 8...
    • CommentAuthoremping
    • CommentTimeOct 19th 2007
     permalink
    A google search brought me here with the following question remaining - why should de CSS be as small as possible (less than 10K) ?
    What would be the effects if you try to load a 36K CSS file from a webserver, would correct css table definitions be less predictable or considered to be unstable for example? I have a case here which involves a 36 K stylesheet, sometimes pictures in a 3 column by 4 rows table is being mixed up like the example below.

    Correct presentation should be:
    -------------------------------------
    1 2 3
    4 5 6
    7 8 9
    A B C

    Becomes sometimes:
    -------------------------
    1 2
    3
    4
    5 6 7
    8 9
    A B
    C

    CSS contains:
    ----------------
    table.fg_table_four_column { background-color:#ecedf4; margin-bottom:1em;}
    table.fg_table_four_column tr { height:120px; }

    #subhome_middle table.fg_table_four_column tr td { font-size:1em; float:left; padding:10px 10px 5px 0; width:80px; vertical-align:top; }
    #subhome_middle table.fg_table_four_column tr td a img { display:block; border:1px solid #8e99c5; margin-left:0px; margin-right:0px; text-decoration:none; margin-bottom:3px; }

    #subhome_middle_long table.fg_table_four_column tr td { font-size:1em; float:left; padding:10px 10px 5px 0; width:80px; vertical-align:top; }
    #subhome_middle_long table.fg_table_four_column tr td a img { display:block; border:1px solid #8e99c5; margin-left:0px; margin-right:0px; text-decoration:none; margin-bottom:3px; }

    #subhome_middle table.fg_table_four_column tr td a:hover img { border:1px solid #cc0000; text-decoration:none; }
    #subhome_middle table.fg_table_four_column tr td.first { padding-left:10px; }

    #subhome_middle_long table.fg_table_four_column tr td a:hover img { border:1px solid #cc0000; text-decoration:none; }
    #subhome_middle_long table.fg_table_four_column tr td.first { padding-left:10px; }

    Hope someone can help. Thanx!
    •  
      CommentAuthorkari.patila
    • CommentTimeOct 19th 2007 edited
     permalink

    Are you gzipping the CSS? You might be able to cut about 70% from your file size by doing so.

    -A quick edit here to illustrate my point. I did a little test with a SkillShare page, in which the combined file size for html and css is around 105k. Add a little gzipping to that, and the combined file size is now 28k. The figures are from WebKit.

    The same amount of reduction will hold for Javascript as well, as long as the files aren't coming from somewhere else. I'm pretty sure that after a couple of simple optimization moves this forum would be flying like nobody's business.

    • CommentAuthorPettyRider
    • CommentTimeOct 20th 2007
     permalink
    You CSS file size depends all on how much CSS is necessary to implement a design effectively in a wide array of browsers. I wouldn't worry about the file size until it's done and works. Then, you can look into preprocessing/gzipping for optimization.
  3.  permalink
    Another possibly helpful tip: if your system has distinct parts. you could possibly break up the css in respective blocks and load them when appropriate. adjustafresh said something along the same lines
  4.  permalink
    emping,

    After a quick look at the style samples you've provided, I don't think that optimizing CSS file size should be your primary concern.

    First off, I'm going to go out on a limb here and guess that you're still using tables to layout your page. That's not going to help your file size. Your ID and class names aren't helping either.

    Specificity in a CSS file is a good thing, but you need to concentrate on the first C in CSS: Cascading. a well written style sheet will establish styles that may be used across an entire layout rather than specifying (the same) individual linked image hover states in individual table cells.

    On another note... I'd like to address my initial statement which is approaching 2 years old. I disagree that "Anything greater than 10 and it's just too large." With ever-increasing broadband penetration and the ability for a browser to cache the style sheet, 10k seems minuscule.
  5.  permalink
    Try this online tool...it's quite useful

    http://floele.flyspray.org/csstidy//css_optimiser.php
Add your comments
    Username Password
  • Format comments as (Help)