Best practices - Only download CSS you need, or use a minification process?

后端 未结 4 526
时光说笑
时光说笑 2021-01-01 03:20

In the context of improving overall site performance (downloading and rendering speed) there appears to be a contradiction between the following two best practices:

4条回答
  •  隐瞒了意图╮
    2021-01-01 03:52

    1. You should use Gzip

    alt text http://shup.com/Shup/376348/1106472221-My-Desktop.png

    http://www.fiftyfoureleven.com/weblog/web-development/css/the-definitive-css-gzip-method

    http://paulstamatiou.com/how-to-optimize-your-css-even-more

    For asp.net

    http://web2asp.net/2009/01/introduction-one-of-big-complaints.html

    Edit:

    2. And write CSS selectors efficiently

    http://code.google.com/speed/page-speed/docs/rendering.html#UseEfficientCSSSelectors

    http://www.stevesouders.com/blog/2009/03/10/performance-impact-of-css-selectors/

    https://developer.mozilla.org/en/Writing_Efficient_CSS

    3. And combining

    http://rakaz.nl/2006/12/make-your-pages-load-faster-by-combining-and-compressing-javascript-and-css-files.html

    RewriteEngine On
    RewriteBase /
    RewriteRule ^css/(.*\.css) /combine.php?type=css&files=$1
    RewriteRule ^javascript/(.*\.js) /combine.php?type=javascript&files=$1
    

    4. Read suggestion from answers of this question CSS Performance issues


    I don't like to have multiple CSS files for each page. 4-5 css files is enough.

    1. Common.css (with reset and common layout and typography and Form styling)
    2. pagespecific.css (css of home and other landing pages)
    3. print.css
    <---- ie only css --- >
    4. ie6.css
    5. ie7.css
    <--- >
    

    And stripping white space from CSS will make edit hard through FTP.

    Here is a good article on one css or multiple css http://css-tricks.com/unique-pages-unique-css-files/

提交回复
热议问题