JavaScript obfuscators

the problem about JavaScript is: first it must be sent to the client. huge applications might take some time to download. another problem is, that users on the client-side can see your code and save it. handgestrickt found some code obfuscators on the web. the special thing is: we wanted to do the obfuscation on the fly. that means we have a folder with access denied to the outside world in which the original JavaScript-sources are stored. a PHP-script takes all these sources and compresses and obfuscates them. that's the theory.

the reality: if you have more than 6000 lines of JavaScript-code, obfuscation on the server-side and deobfuscation on client-side take very long. additionally errors are thrown. this is because removing comments and doing "automatic semicolon insertion" are delicate and complicated tasks. especially Prototype.js is missing some semicolons, which is conforming to ECMAScript, but if you try to make one line out of the code, the missing semicolons throw errors.

in the end we discarded the idea to obfuscate and decided for Douglas Crockfords JSmin, a JavaScript-minifier, which deletes comments and whitespaces, taking care of "automatic semicolon insertion". then we pass the result through gzencode() (which is originally based on the CSS and JavaScript Combinator 0.5 by Niels Leenheer) to compress it. this makes the code 10 times smaller and faster to load. by the way: the JavaScript-code is still hard to read.

related:
JSmin
gzencode()
CSS and JavaScript Combinator 0.5
JavaScript
PHP
ECMAScript
"automatic semicolon insertion"
Prototype.js

Saturday, 07. April 2007 • trackback url

Add Comment

( to reply to a comment, click the reply link next to the comment )

Comment Title:
Your Name:
Email Address:
Make Public?
Website:
Make Public?

Comment:


Allowed XHTML tags : a, b, i, strong, code, acrynom, blockquote, abbr. Linebreaks will be converted automatically.


Captcha:

captcha image

please type the content of the above image into the following form-field: