Skip to content

HOWTO use Juicer to compress javascript and css

reebalazs edited this page Dec 7, 2011 · 6 revisions

=============================================== HOWTO use Juicer to compress javascript and css

Installing juicer

You need to do this installation on your desktop, if you want to

  • run KARL in javascript development mode (js_devel_mode = true),

  • or, you want to recompress the javascript and css resources with bin/juice_all.

In all other cases, you won't need to do any of the followings. Especially: none of this is ever needed in production.

Installing ruby

Debian/Ubuntu::

 $ sudo aptitude install ruby

MacOSX::

 $ sudo port install ruby

(Windows: if you are on windows you have to figure this out.)

... the following steps are the same on all OSes.

Download RubyGems from http://rubygems.org/pages/download . Unpack to a directory, and install it::

 $ sudo ruby setup.rb

Installing juicer

Install juicer itself::

 $ sudo gem install juicer
 $ sudo juicer install yui_compressor
 $ sudo juicer install jslint

You must also have java installed. (probably nothing needed to do, if you have java)

Preparing the KARL tree

To allow development mode or juicing to work, some sources are needed that need to be checked out manually.

cd to your buildout root, go to KARL the static directory in the sources::

 $ cd src/karl
 $ cd karl/views/static

Check out bottlecap as static/bottlecap::

 $ git clone [email protected]:Pylons/bottlecap.git bottlecap

Recompressing the resources (rejuice and rejoice)

Go to the buildout root, and execute::

$ bin/juice_all

You will get plenty of warning spewage from jslint (Verifying…) . This is because most of the libraries out there get warns from jslint. Still no problem, as this is a warning, although it would be better to filter out this quite useless log text.

If all goes good, you get this message in the end::

##### All files compressed OK

If the compression of any resource fails, the script will stop at that point and will give you the exact juicer command line that it tries to call, and the error response that juicer gave.

Troubleshooting

Juicer documentation is here: http://cjohansen.no/en/ruby/juicer_a_css_and_javascript_packaging_tool