Crosstips.org

My fun Crossword solver project. Crosstips.org & Krysstips.se

Kung Fu

Fujian White Crane Kung Fu

Fry-IT

Fry-IT is the company I work for

Photos

Photoalbum, both old and new.

Zope

What I have and am doing with Zope

Receptsamlingen

In Swedish only. About my "Collection of Recipes" website.

Contact me

My contact details and how to contact me.

 

KungFuPeople.com
Do you train Kung Fu?
Or know someone who does?
Then check out KungFuPeople.com


Mobile version of this page Mobile version of this page


 

Comparing YUI Compressor and slimmer

http://developer.yahoo.com/yui/compressor/

17th of November 2009

YUI Compressor apparently supports compressing CSS. Cool! I had to try it and what's even more cool is that it's the only other CSS minifier/compressor that doesn't choke on CSS hacks (the ones I tried). The only other CSS minifier/compressor is my very own slimmer. So, let's see what the difference is.

Running the YUI Compressor 10 times on a relatively small file takes 0.3 seconds on average. Running the same with python 2.6 and slimmer.css_slimmer takes 0.1 seconds on average. I think most of this time is spent loading the jar file than the actual time of running the compression.

Here's how I ran yuicompressor:

 $ time java -jar yuicompressor-2.4.2.jar --type css tricky.css > compressed.css

And for slimmer I first had to write a script:

 from slimmer import css_slimmer
 import sys
 print css_slimmer(open(sys.argv[1]).read())

And run it like this:

 $ time python slim.py tricky.css > slimmed.css

If part of a build system, 0.3 or 0.1 seconds don't matter. YUI Compressor has the added advantage that it's popular which means many eyes on it for submitting bug reports and patches. However, if you're already in Python and don't want to depend on manually downloading the jar file and running a subprocess then slimmer is probably a better choice.



Comment

Steve Lacy - 17th November 2009  [«« Reply to this]
I think you left out Google's Closure compiler, which explicitly states "The Closure Compiler reduces the size of your JavaScript files and makes them more efficient, helping your application to load faster and reducing your bandwidth needs." http://code.google.com/closure/compiler/
Steve Lacy - 17th November 2009  [«« Reply to this]
Whoops, you're talking about CSS, not JavaScript. Should have read the post. D'oh.
Carl Meyer - 17th November 2009  [«« Reply to this]
Hey Peter - might want to fix the note on slimmer's PyPI page that proudly claims "still maintained in 2008." It no longer gives the impression of up-to-dateness it might once have done ;-)
Peter Bengtsson - 2nd December 2009   [«« Reply to this]
Thanks for noticing. Done
Christof - 17th November 2009  [«« Reply to this]
Would you post the "tricky.css"? Wonder ig yuicompressor and slimmer will actually cope with any css hack out there (especially syntactically invalid ones... ;). That would be nice, thanks
 
Name:
Email:
hide my email address.

Your email address will be encoded to prevent email-extraction spiders from reading it so you won't get spammed if you decide to show your email address.