Wednesday, July 22, 2009
First, about compression and obfuscation.
I found it most productive to use combination of two separate tools: a popular compression tool JSMin (available in 10 different languages, I am using Python version) and ShrinkSafe, an obfuscation/compression tool written in Java.
java -jar <path>/shrinksafe.jar <original>.js | jsmin.py > <new>.js
Next step is to use a Python utility jsprocess.py which I wrote. It is reading a list of Python input files and is looking for all calls to the utility inline_js() (which must not exists other than version created by a previous run of jsprocess.py). For very call which looks like inline_js ("file_name.js"), e.g.
fh.write ( inline_js("docform.js") )
it will append to the end of the file definition of inline_js() which embeds compressed/obfuscated copy of "docform.js". If function inline_js() is already defined (anywhere), it will be replaced.