While I still haven’t got around to releasing my python port of the yui-compressor (I will soon, I promise), my plan had originally been to extend the compressor into an optimising compiler for javascript – but I just stumbled upon the a Google project that seems to have beaten me to it.
The Closure Compiler (google code page) does exactly that – it takes your javascripts and optimises them for both filesize and run-time.
I haven’t looked too deep yet, but it seems that it uses the parser from Rhino, and augments it with an implementation of a javascript AST, and an optimiser that works on the generated AST.
The Closure compiler is written in Java – anyone who feels like working on a python version is likely to find pynoceros (the python version of Rhino’s parser I annouced a few weeks ago) useful.
Tags: javascript












Why reinvent the wheel? You can probably use Closure directly from python via JPype http://jpype.sourceforge.net/ or via a REST webservice.
I hadn’t come across JPype before, although I have used Jython, and considered using it for similar things.
You’re right about reinventing the wheel – in fact the Closure compiler is available as a publicly available web app, which is very useful.
regarding pynoceros – it’s a non-work project, so it was half for fun rather than productivity – on the other hand it’s quite a central component in a lot of useful projects, so it’s nice to have a version in the language I use the most.