Juicer is a CSS and JavaScript packaging tool developed by cjohansen. I personally use Juicer to compress my multitude of nicely formatted CSS files into one neat minimized file for deployment. This minimizes the number of requests made to my servers and speeds up my websites. For more information on this visit this page.
First up, I’m going to assume that you’re already running Mac OS X 10.5 (Leopard). If not, you’re going to need to first follow this brilliant tutorial on setting up Ruby on Rails for both Mac OS X 10.4 (Tiger) and Mac OS X 10.3 (Panther). Even if you are running Mac OS X 10.5, I still recommend that you follow this tutorial to roll your own Ruby on Rails installation (however, it is not a requirement). I also recommend that your system is fully updated ( -> Software Update).
Now we’re going to go start Terminal and run the following command (Terminal is available from the Utilities sub-folder of your Applications directory): sudo gem install bones juicer. It will likely ask you for your password, which will have to enter to continue the installation.
Next up is to edit your .profile file so that the juicer commands will work. Your command promp should already show that you are in your user directory (ComputerName:~ username$), if not then navigate to it. If you do not know the basics of using Terminal then I recommend you visit this helpful tutorial to get better acquainted. Now that you’re in your user directory you can execute the command vi .profile, and you should see something similar to this:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
##
# DELUXE-USR-LOCAL-BIN-INSERT
# (do not remove this comment)
##
echo $PATH | grep -q -s "/usr/local/bin"
if [ $? -eq 1 ] ; then
PATH=$PATH:/usr/local/bin
export PATH
fi
All we’re going to do is add our path to the end of the file. So press ‘i’ and use the arrow keys to navigate to the end of the file. Press ‘return’ a couple of times and then copy and paste the following code:
export PATH="$PATH:/var/lib/gems/1.8/bin"
Now press ‘escape’ and then enter :wq, and press ‘return’ to save and quit. We can now run the next two commands in Terminal to install YUI Compressor and JSLint.
juicer install yui_compressor juicer install jslint
(Execute them one line at a time). Now we can get on with using Juicer itself, which is as simple as:
juicer merge first.css second.css
This will merge the two CSS files into one single file (first.min.css), which can then be copied onto your server and referenced instead of the multiple files that you had before. If you wish to see other examples of Juicer than make sure to check out this page.