More elegant way (at least for me) to do this is the server-side compression (whitespace stripping) on-the-fly, which can be for example done by a small (but experimental) module called mod_ext_filter for The Apache web server. This module provides very easy way to do almost any post-processing. For example post-processing of style sheets or any markup language code.
Easy way in this context means that you have to write a few lines of C/C++ code (or if you don’t speak C, you can use the shell script or anything you are familiar with) which will read the content from the standard input, strip whitespaces (and possibly all comments and other garbage) and return it to the standard output.
Module mod_ext_filter also supports cacheable output, so you don’t have to handle it in your code. And you have to never think about not forgetting to compress your new style sheets or code again. You simply publish it and forget.