Tuesday, October 6, 2009

Python Javascript Bundle

The jsBundle Python package is a nice little utility for building deployment-ready javascript modules. As the same suggests, jsBundle is used to bundle several javascript modules that make up the front-end of a web application. Many web applications will simply serve the javascript modules as is. That is, the source code of the javascript modules is distributed in the application with no modification or compression. This approach is perfectly acceptable when the logical arrangement of javascript modules are simplistic. When there are many javascript modules, some of which might be fairly large in size, a more managed deployment approach should be taken.

There are several javascript compression and bundling utilities available today. There also exist server-side libraries that allow server code to be written that will actually generate the required front-end javascript. The main problem with this approach is that there are too many corner cases where the inflexibility of these server-side javascript libraries do not allow for optimal javascript to be generated. Some web applications might have a well organized javascript package arrangement that is well balanced. What the developers might do is use a javascript compression utility to compress each javascript module. The problem here of course being that it is hard to maintain this approach.

The jsBundle makes this much easier by allowing for any arrangement of javascript modules to be compiled into a single, compressed module that is given to the application front-end. Additionally, jsBundle is also capable of generating API documentation, an area largely neglected for javascript. One final aspect of jsBundle worth noting is that it is especially handy to use if your server-side application is implemented in Python. jsBundle can then easily integrate with the web application distribution.