Barry van Oudtshoorn has written a CSS minifier that uses some of the same concepts that Ray talked about (ordering for best compression). Here is Barry:

I recently wrote a small CSS minifier in Java that optimizes your CSS output for gzipping. Essentially, it does most of what the YUI compressor does, but additionally, it ensures that property values are always ordered consistently. This means that the gzip algorithm can reduce the file size further.

In my testing, my CSS minifier’s raw output is actually slightly larger than that of YUI, but when compressed, it is noticeably smaller, thanks to the gzip optimisations. As this is the an early release, however, I have plans for various optimizations to the raw output which will further reduce its size, which in turn will help to reduce the gzipped size of the file even further.

The code is released under the MPL, and is freely downloadable from my website, at the address linked to above.

Does the alphabetizing thing really help if you follow Google’s recommendation to use CSS rules only once? Sure, there are some rules like padding where you may have different values for the property, but it seems a bit negligible.

I’ve also been alphabetizing properties for readability for a while, at first it feels counter-intuitive to have for example height before width, but then after a while it becomes natural – and firebug does it automatically too.

@ywg is right though, the order can be sensitive to the style so it could break layout if you made it an automated process – best to have some kind of pre-commit hook that rejects if it see’s properties out of order…