This function, comprised of a simple regular expression, will remove most of the bloat from larger CSS files.  Not that the effects are very substatial or groundbreaking, but it does save quite a few kilobytes to run things like this over your CSS and HTML.  Using mod_gzip also has a favorable effect, but this cannot hurt either.  If you find any real bugs, let me know; if it's something completely pathological and contrived, don't let me know.  I have another filter for HTML; but I'll post it another day.  Here it is:

<?

function trimCSS($str)
{
    return 
preg_replace('#(?<=[:;\w{])\s+(?=[}\w;:\#])#'''$str);
}

?>

Tell an amigo:
  • Sphinn
  • Digg
  • Reddit
  • del.icio.us
  • StumbleUpon
  • Facebook



Related posts:
ROTD: Replacing "Smart" Quotes with "Dumb" Quotes Microsoft applications have this nasty habit of exchanging both your...
CSS Spam and Robots.txt What really stops anyone from using a CSS-based layout, throwing...
A (not so simple) method to add rel="nofollow" to links I wrote this script so that I can run it...
Checking for Dead Links Automatically This neat little class can return the HTTP status code...
ROTD: Mod_rewrite Rule To Remove Trailing "index.php" This handy set of rules for mod_rewrite automatically redirects any...