JSO is officially retired because:
For those who want a good obfuscator, I have compiled YUI Compressor into a Win32 executable. I do think YUI Compressor is better than JSO because:
with keyword (not recommanded anyway...) The only down side is the compiled Win32 executable is 37.6MB and 8.3MB compressed:
I hope everyone can enjoy coding.
[skip to the Description if you don't want to read the nonsense]
Thanks to Google, JavaScript becomes a hot technology again. Mr. Jesse James Garrett coined the technique utilizing JavaScript and XMLHTTPRequest as AJAX. Whatever it is called, I believed that it is the most natural way for both web application developer and web users if the web application have to be an RIA (Rich Internet Application). However, there is an important issue to deal with before it can grow. All JavaScript are basically plain text. What problem?
I believe that the adoption of AJAX will grow only if there are enough number of components avaiable in the market. However, if you can't protect the code, are you willing to spend the time to develop the components? So, the answer is obfuscating the source code.
As I searched on the web, only a few obfuscators are available. All of them are useless for component developer. Imagine that you have written a JavaScript component, say TreeListView (google it if you don't know). You would like to share the scripts but you don't want others to see how it works (avoid other parties from stealing it and selling it). You tried the obfuscator to scramble the code. Then, you found that the names of classes, public variables and the public functions are renamed. Would you pay that obfuscator? Would you release the component you've written without any protection (substitude "you" to "a company")?
To encourage everyone using JavaScript, I decided to write this obfuscator by observing how I wrote the code and then release it to the public.
about your thought.
The obfuscation rules are:
Implications from the obfuscation rules:
with should be avoidedwindow object, it is better to explicitly write window.something (e.g. window.setInterval...) "asod asdi".replace(/as/gi, "cool") "asod asdi".replace(/ab/bb,"cool")"asod asdi".replace(new RegExp("as", "gi")) insteadThe output will be printed to STDOUT if the destination directory is not specified. Also, a mapping of old_variable=>new_variable will be printed to STDERR.
[Download Source][Download JAR][License]
Win32 executable is also available. However, due to the restriction of the server (it's free anyway), I have to split it into pieces. Please simply download the pieces and run the batch file (generated by JR File Split). It will reconstruct the Win32 executable (thanks to tElock 0.98, it compressed the 8.53MB executable into a 2.43MB one.).
javac JSO.java
java JSO <list of javascript file> [options]java -jar jso.jar ... jso ... where the options are:
Obfuscate all scripts in the current directory and output to ./out directory
java JSO *.js d=out
Pipe the STDOUT output to x.o.js
java JSO x.js > x.o.js
Obfuscate class member preceded by "_" or "__" (e.g. this._foo )
java JSO x.js p=_,__
Merge a.js and b.js and pipe the merged output to script.js. Tokens in exception list, noReplace.txt will not be replaced.
java JSO a.js b.js e=noReplace.txt > script.js
Obfuscate the 100% of token in string literals, 68% of the characters will be encoded. 50% of the character will be encoded as \uXXXX format (default)
java JSO x.js o=1,0.68