ObfuscateJS : Javascript Obfuscator

Compress your JavaScript files

Important!
Make shure you have the latest 0.3.x version, the 0.2 version contained a major bug, which prevented the best features from happening!

Keeping files small is important for websites. With the hype around AJAX technology, the use of JavaScript increases and reducing the size of Javascript files becomes important. Besides rendering files unmaintainable (so copy/pasting your code becomes much harder), an Obfuscator has the effect of greatly reducing the filesize. This compression has a positive effect on the speed of your website.

In need of a good Javascript Obfuscator during the development of the Consyn AJAX Framework, 2Vi created a free JavaScript obfuscator in Java. This project is now named ObfuscateJS.

The obfuscator currently removes whitespace and comments. It renames variablenames with a local scope to a shorter version, And as an advanced option it renames all variables with a certain prefix to a shorter name. In the near future the tool will be extended with even more options to shorten variable names.

An important aspect of ObfuscateJS is that it preserves the API of your scripts. This is important when creating libraries such as the Consyn Framework.

Usage

After downloading, in order to apply ObfuscateJS to a file, the following command must be used:

java -jar consyntools.jar Obfuscator {src} {dest} {prefix}

{src} : The sourcefile
{dest} : The output file
{prefix} : The prefix of variables, which can be renamed without problems

In order to explain the 'prefix' option, let's look at the following code:

function _debug(){...}
...
_debug();

Now if we choose '_' as the prefix, this code will be rewritten as:

function _a(){...}
...
_a();

This prefix can be ommitted, in this case only local variables are rewritten.

Support

If you have any problems with the rewritten scripts, please mail me the (critical part of the) original script and the error message. You can also mail me with suggestions for improvement of the ObfuscateJS JavaScript Obfuscator. Please check out the list with known bugs first.