March 6, 2009
- Got concatenation working for both js and css
- Added minification support via YUI Compressor
This second item in the list leads me to a question about best practices when creating a re-distributable Django app. Minification support is an optional flag passed at run time to build your css/js:
./manage.py compact --minify
If specified, it will run the concatenated files through the YUI Compressor minifier. Since this tool is java based, and not python :(, I decided to include the jar file in a lib folder under the application folder.
I then created a module called
yui.py and encapsulated the shell out via
Popen in a python class called
Compressor. This does assume that the
java executable is in your path and is of a version greater than 1.4 (YUI
Compressor requires at least 1.4).
The question I have is, is there a best practice of where and when to include
binaries such as this? I feel that this is pretty clean in that I construct
the path to the jar dynamically at run time so i don't assume any particular
install location. I could do more up front checking for the existence of
java and the version number.