Ruby Juicer: Combine / Merge and minify CSS files

Written by
Date: 2012-07-22 09:10:32 00:00

Minifying css and javascript is a good practice, too often it is over-valued, but a good practice anyway. Why over-valued? Because it is a lot better to enable gzip for your css and js files than minifying them, but do both if you can.

On the other hand, combining css and js files is really a good practice, this is because more calls to the server for more files, when only one call for one big file can be done, really improves load times.

But the good news is that you can address both issues with just one command line. Using ruby juicer command.

Installing Juicer

gem install juicer
juicer install yui-compressor

Minify and combine CSS files

juicer merge first.css second.css third.css

The output will be first.min.css and because of yui-compressor, the output will already be minified.


If your css files include @import directives, juicer will replace that line with the contents of the file to be imported, generating one big-minified CSS file for you.

Be sure to also enable gzip on your server. Here is How to enable gzip on Apache