![]() | WebSiteOptimization.com |
| Home Sitemap Publications Services About Contact |
CSS optimization is the process of minimizing your markup and CSS files for maximum speed. You can employ some of the same techniques to optimize CSS that you learned in Chapter 3, "HTML Optimization." Whitespace removal, cutting comments, crunching color values, and embedding code with SSI are some of the techniques common to both CSS and HTML optimization. CSS gives you more flexibility than HTML or XHTML, however, because you can make up your own names and group rules together to save space.
You'll reap the greatest rewards by using CSS to transform your code into a more rule-based modus operandi. Converting old-style table/font layouts into XHTML/CSS-style code typically saves 25 to 50 percent off file sizes and gives you the benefits of adaptable structure and separate presentation. You can use layering and inheritance to save space and increase compatibility, and use shorthand properties to shrink your CSS code by up to 50 percent. This chapter gives you the tools you need to optimize your CSS.
Use CSS to strip presentation out of your (X)HTML. To optimize your CSS group external files to minimize HTTP requests, remove whitespace, and use shorthand properties. Group common declarations, selectors, and CSS code in multiple classes to save space. Use the simplest selectors you can, high in the document tree and let them cascade. Be as vague and as abstract as possible in your CSS selectors.
Copyright © 2002-2008 Website Optimization, LLC - Free website speed test - Privacy Policy
Last modified: June 19, 2004