Michael Kerrin

Web, Python, JavaScript and related technologies

Archive for February 2011


with one comment

Its been a while but I am going to be releasing some open source packages in the near future.

First up is pwt.recipe.closurebuilder. This is a zc.buildout recipe that integrates with closure-library build system. Then pwt.recipe.closurebuilder makes it easy to find and minify all your JavaScript files that make up your application into one or more files. Obviously if you don’t use zc.buildout that it is not going to be of much use, but the idea behind the closure JavaScript dependencies is worth reading about IMO.

pwt.recipe.closurebuilder contains two recipes. One to generate a JavaScript file containing a database of dependencies between all your JS files using closure library namespaces. This is equivalent to the depswriter tool from Google.

The second recipe invokes the closure compiler to produce a minimized version of your code base. It uses the information gathered through the first recipe to find a list of all the files that you want to collect and minify into one small JavaScript file. This file is saved in a output directory specified by you and whose name is the md5 sum of the contents of the generated JavaScript file. This recipe is equivalent to the closurebuilder tool from Google.

The closure compiler is the best JavaScript to JavaScript compiler out there that minimizes your code the most. But using it repeatable and consistently can be a problem. As I use zc.buildout whenever possible integrating the minimization of your JavaScript into my build system of choice makes life easier.

Written by mkerrin

2011, February 22 at 9:08 am