Tuesday, May 31st, 2005
Utility: JavaScript Obfuscator
<p>Shane Ng has releaed an open source JavaScript Obfuscator. The obfuscator is a Java program itself, and follows a set of rules:- This JavaScript obfuscator removes all comments.
- In case there is a closure that does not end with a semi-colon, “;”, a line break will be inserted when “}” is encountered.
- Redundant whitespace characters (tab, space, new line) will be removed.
- Variable names and function names are replaced only if they are not the member of the class.
- this.x, document.write() will not be replaced.
- Generally, the name after a dot, “.”, will not be replaced.
- Variable names and function names will not be replaced if the token
- is a member of a class as mentioned at #4
- starts with a capital letter (assuming they are classes)
- is
in the exception list. The exception list can be specified in a file
delimiting the tokens with whitespace characters (tab, space), dot
(“.”), comma (“,”), double-quote (“”"), and single-quote (“‘”)
- If specified, tokens in string literals will be encoded into uXXX or XXX format
- If a line is end with a JavaScript delimiter or a double-slash comment, it will merged with the next line to a single line
It is still pretty new, so you have to watch out for issues. For example, it really wants you to use semi-colons after statements.
Download the obfuscator Jar file
Related Content:











He who needs to use an obfuscator for JavaScript (!) shouldn’t be “programming” in the first place. But that’s just my opinion.
There is also this http://www.saltstorm.net/depo/esc/
“ESC is an ECMAScript pre-processor written in JScript, enabling an unlimited
number of external scripts to be compressed into supertight…”
can do Obfuscation as well.
Dojo is using a custom Rhino build to accomplish much the same thing:
http://dojotoolkit.org/~alex/js_with_compress.jar
Since it’s built on the Rhino parser, it’s pretty solid and not prone to the kinds of bugs that most regex-based processors fall prey to (including the earlier ones I’ve written).
Regards
wow! can we have this compressor,alex ?
I’ve searching for a good tool like that
Of course, just grab that jar file and invoke it like:
java -jar js_with_compress.jar -c infile.js > outfile.js 2>&1
Since the “compressed” version gets sent to stderr, the second redirect is required.
Hope that helps.
Regards
Shane’s web site has been unreachable for a while now, so I put his excellent obfuscator at my web site. If you need it, it’s at: daven.se/usefulstuff/javascript-obfuscator.html
Could not download the JAR file
Can someone post a mirror as the site has been taken.
thanks
I’ve tried many JS obfuscators and optimizers and most of them are buggy :( I’ve used Jasob and w3compiler for some time but eventually found TrickyScripter (http://trickyscripter.com) and I like it more than anything else now. The bad news is that it is a Dreamweaver plugin :( Hope they will release an executable for Windows soon.
The compressor has been rolled up into a new JAR at:
http://dojotoolkit.org/docs/compressor_system.html
JavaScript Online Obfuscator is a integrated solution for confusing javascript source code. It confuses local variables, arguments of functions and methodes, but doesn’t confuse javascript core and client’s classes, functions, methods or properties. It is compatible with Core JavaScript, Client-Side JavaScript, W3C DOM, XML, XML Schemas(SOM), XSLT, AJAX(XMLHTTP) and other third party object. You may decide if confusing your owner’s global variables, classes, functions, methods and properties in source code, according to obfuscating rules. It is easy to use, doesn’t need complex operating and large configuration file.
http://www.bizstruct.com/javascriptonlineobfuscator/
Online JavaScript Obfuscator has changed to
http://www.bizstruct.com/online-javascript-obfuscator/
Online JavaScript Obfuscator has moved to
http://www.JavaScript-Obfuscator.com/
i wasnt able to download the file, :( I want to include it on http://www.greenlush.com
I am looking for utility to convert javascript into vbscript
The link doesn’t work but I found the javascript obfuscator here:
http://shaneng.awardspace.com
http://iframe.in/
This site will help you quickly encode and obfuscate your HTML/JavaScript code many different methods, as well as generate browser redirect or hidden iframe on JavaScript or Flash.
R.I.P.
The dojo rhino obfuscator is still around.
The new link is: http://dojotoolkit.org/docs/shrinksafe
That obfuscator is not available anymore. In need of one, I wrote it and release it as open source. You can check it out at http://digua.sourceforge.net. It also works for HTML and CSS.
did you try javascript obfuscator from http://www.javascript-source.com/ ?
they promise the best compression ratio for js code. is it true?
it’s commercial :(, but a trial is full-functional.
Javascript is a critical component of today’s Web pages. It was important back in 2005 but now it’s everywhere. Yesterday i noticed that 90% of the top 10 000 websites use Javascript: http://trends.builtwith.com/docinfo/Javascript
This is huge!
For me the most important developer in Javascript obfuscation / optimization / compression are currently:
Google Closure :
Because of the high performance minification and optimization.
JScrambler:
Because they try to do it all: compression and protection and are very effective at both.
And for me one the most important features is that both are actively developing their platforms.
The best obfuscator compressor better than YUI os Google,
http://javaencrypt.com/javascript-obfuscator/index.php?lang=en
Recent javascript obfuscator\minifier tool project.