Tuesday, May 31st, 2005
Utility: JavaScript Obfuscator
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












He who needs to use an obfuscator for JavaScript (!) shouldn’t be “programming” in the first place. But that’s just my opinion.
Obfuscation is just a tool to make your js code harder to read and it also compresses it a bit for you. It has nothing to do with your ability to program. Maybe you meant something else or I missed the connection there…
In any case, here’s another nice one written by Dean Edwards:
http://dean.edwards.name/packer/
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
1 jalka http://www.1-jalka.s3ksss.com [URL=http://www.1-jalka.s3ksss.com]1 jalka[/URL]
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.
links of london
links oflondon charms
links oflondon necklaces
discount links of london
links oflondon bracelets
links oflondon bangles
links of london sale
links oflondon earrings
links oflondon rings
links of london jewellery
CharmBracelet
SweetieBracelet
links oflondon sweetie bracelet
christian
louboutin
christian
louboutin shoes
christian
shoes
louboutin
shoes
christian
louboutin sale
christian
louboutin discount
christian
louboutin sale
Christian Louboutin Boots
Christian Louboutin Pumps
Christian Louboutin Shoes
Christian Louboutin Sandals