22 November 2006
Thinking about CSS compression
Posted by Barnabas under: Programming .
Today I stumbled across a post comparing online CSS compression services. More mobile devices support more advanced CSS, so I got to thinking: how could we make mobile CSS work better in Skweezer? Currently it’s either “on” or “off.” I read over the PHP code in the recommended service (very nice!) and I see that it does the following:
- Remove comments and whitepace
- Optionally convert colors to hex values, and shorten hex values where appropriate
- Remove zero measurements
- Sorts the CSS and combines identical selectors
- Combines properties
- Combines or removes empty rules
Because Skweezer also mangles optimizes the original HTML as well, I was thinking that in addition to the above compression techniques, Skweezer has the latitude to do the following operations:
- Remove all properties related to position or advanced CSS that phones can’t use
- Detect and remove browser-specific CSS hacks
- Compress the selector names themselves using a hex identifier
- Embed the CSS in the page if short enough? Not sure on this one…