mjs_py - JavaScript minification
This is just a very basic script I used to minify JavaScript using Google's Closure Tools web service or a local jar version when I'm without a connection. You can grab it from my bitbucket repository. Note: This is a pretty pants implementation but it does the job.
Any updates probably won't come for some time as I'm certain I will write something myself to minify Javascript purely in Python rather than rely on a free web service that may or may not be around in a week's time but I decided to share what I've done so far just in case it is of some interest to people.
For those who may be curious, this is how I've implemented the local compiler (which is why the java.jar is required).
import subprocess retcode = subprocess.call(["java", '-jar', 'compiler.jar', '--js', js_source, '--js_output_file', '%s_min.js' % (js_source.split('.js')[0])]) if retcode == 0: print 'Minification process completed successfully and %s_min.js has been created' % (js_source.split('.js')[0]) else: print 'Error %s' % (retcode)
It's just a simple subprocess usage. I'm not a huge fan of doing things this way but it works and if you like subprocess then it's very handy indeed!