JavaScript Obfuscator and Minifier

This tool is based on a full JavaScript parser that is part of a much bigger plan. I won’t go into that just yet, but along the way I’m going to be releasing useful tools like this as they come about. It’s useful to have some short term goals to keep up morale and ensure that the framework is working well.

> Try it here: Obfuscate and minify your JavaScript code


There are other minifiers out there;

[ Link to project removed due to incredibly rude email from its author ]

The parser framework behind my attempt allows a great deal more power at the expense of being a much heftier package. The source code is about 700k, so this is anything but light-weight. The extra power means that, unlike many minifiers, line breaks are not required at all. Any JavaScript program can be stripped down to one, very long line of code. The reason for this is that it performs automatic semicolon insertion. It can do this because rather than just performing a lexical scan of the source, it compiles the full syntax of the program into a parse tree. Of course, a program with a syntax error will not be minified, but then why would you want it to?


Another advantage of the syntactical parsing is that we stand a better chance of safely altering identifier names. This still has serious limitations though, because the code is still not actually being executed there are many situations that could result in disaster. The current version obfuscates all explicitly named, top-level entities, such as function names, function arguments, labels, and variable declarations. Member expressions are particularly problematic, and so I have not attempted to obfuscate these. I may at some point in future work on improving this, but as this is only a side project, I am not going to hold my breath.

You can always take additional steps in your original code to better preprare for effective obfuscation. Consider this;

var myDocument = document;
var myElement = myDocument.getElementById('myId');

Try it and see