Monday, September 27, 2004

CSS Manageability thru Gzip Compression and PHP

Working with CSS can sometimes present problems other than cross-browser compatibility and hacks. They often lead to large and increasingly unmanageable labors of love. Reuse of your CSS in other designs can be tedious cut and paste jobs, in which you sometimes are just better off starting over from scratch.



Enter FiftyFourEleven's Mike Papageorge with a unique approach of organizing and optimizing your CSS. Mike utilizes modularized stylesheets by function (navigation, colors, hacks etc.) then "stitches" them together with php. The stylesheets themselves are parsed as php also, in which you can comment to your hearts content without worry of that content being sent when the sheets are called from the server.



There are advantages over the normal way of @importing complex function sheets from one basic stylesheet. His method delivers one transparent single stylesheet. He goes a step further with a simple method of Gzip compression and cache control via the php file to deliver this large stylesheet with amazing quickness. An Opera Browser side-effect of actually being able to see individual stylesheets being loaded one after the other is now being served just the one -- and the results (from what I read) are that the page loads very cleanly.



There is a reference in Mike's articles to Andy King's book, Speed Up Your Site, in regards to decompression inconsistencies of .css files between browsers. If you do not have his book, you can still peruse some of the Http compression information at his website.

No comments:

Post a Comment