cssmin.js
cssmin.js is a JavaScript port of YUICompressor's CSS minifier.
The motivation
Minifying CSS helps reduce file sizes and makes your pages faster and your users happier. YUICompressor is cool but is written in Java, which can be a blocker for some folks - you know JVM, command line, classpaths... No more excuses, now you have a simple light JavaScript version. And as you know, JavaScript is everywhere, so you can run it however you want, integrate with your editor and so on.
The links
The integration
If you want to integrate the library into your environment, it's really easy. It's just one file with one function in it. So, just a simple function call:
var result = YAHOO.compressor.cssmin(input_css_code);
The credits
Julien Lecomte - creator of YUICompressor
Isaac Schlueter - he maintains the YUICompressor and is the author of the original cssmin utility which was ported to Java by Julien.
Ha, what about a quiz? Guess the language of Isaac's original cssmin and I'll send you a free copy of Even Faster WebSites and I'll sign my chapter. Seriously.
UPDATE: For Ruby folks, there's a Ruby port from the Ryan Grove.
This entry was posted on Wednesday, September 23rd, 2009 and is filed under CSS, JavaScript, performance, yui. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Get notification for future posts: follow me on Twitter or subscribe to my RSS feed

September 24th, 2009 at 12:02 am
I’m going to guess Isaac wrote it in PHP
September 24th, 2009 at 12:08 am
[...] First Tweet 15 minutes ago stoyanstefanov Stoyan Stefanov Highly Influential New blog post: cssmin.js http://www.phpied.com/cssmin-js/ view retweet [...]
September 24th, 2009 at 12:11 am
heh, the shortest contest ever
Greg, send me your mailing address to ssttoo at gmail
September 24th, 2009 at 12:18 pm
Add to the end for correct work in IE6
//:first-letter and :first-line for IE6
css = css.replace(/:first-letter+/g, “:first-letter “);
css = css.replace(/:first-line+/g, “:first-line “);
September 24th, 2009 at 4:25 pm
Thanks P.Sorokin!
October 3rd, 2009 at 12:03 pm
[...] phpied.com Stoyan’s blog about (x)html, ajax, bookmarklets, browsers, css, firebug, javascript, json, mdb2, mysql, pear, performance, php, phpbb, tools, yslow, yui, writing, music,… life and everything. « cssmin.js [...]
February 14th, 2010 at 11:06 am
I need a perl version of this script, for server side optimization…