Sqweeze

A command line web asset optimisation tool.

Features

Sqweeze cuts the unnecessary bytes out of your web assets, helping you delivering your web project more fast and efficiently. With a little help from a number of well known open source third party tools, Sqweeze does the following:

  • Lossless compresses .PNG, .JPEG and .GIF image assets.

  • Compresses and concatenates into single files multiple Stylesheets and Javascript files.

  • Embeds the compressed assets referenced into the stylesheet, using using Data-uris (for proper browsers and IE8) and MHTML (for IE6-7).

  • Finally, it provides some basic functionality for linking the compressed Javascript and CSS just created to the main HTML document, and removing automatically the links pointing to the old uncompressed ones.

Installing it

Sqweeze relies on a few command-line image compression tools, namely Pngcrush, Jpegtrain, and Gifsicle, which have to be installed first. On an Ubuntu box, you can install these by running a single command line

sudo apt-get install pngcrush gifsicle libjpeg-progs

(This assumes you have ruby, ruby1.8-dev, and gem installed).

Mac OSX users can install the first two as Macports packages. The third (part of libjpeg) instead, has to be compiled manually.

Once installed these, you can install Sqweeze using rubygems

gem install sqweeze

Configuration

When run for the first time, the script creates a config file in the user’s $HOME directory and sets therein the default paths of command line tools such as pngcrush and friends.

# file $HOME/.sqweeze.yml

bin_paths:
   - pngcrush: /usr/bin/pngcrush
   - jpegtran: /usr/bin/jpegtran
   - gifsicle: /usr/bin/gifsicle

If you have installed these anywhere else than in /usr/bin+, you will have to edit this file so that sqweeze can find them.