Is there a recommended javascript code obfuscation tool?
I have searched it in stackoverflow,and someone suggest the ‘YUI compressor’.
However it just do the following:
-
remove the annotatation/white space/new line
-
replace local variable
-
or something ele.
But It does not replace the property of one object.
Say I have a code like this:
var a=obj.fun();
var b=obj.pro;
I want something like this:
var xxx,yy,zz;
xxx=obj['yy']();
yy=obj['zz'];
Then even people re-format my code,he can not even know the propery/methods of one object unless he re-do the method/property replacement.
This is just an example, I just want the tool do more obfuscation other than just compress.
Any suggestion?
You should try the google closure compiler, it provides three levels of writing:
WHITESPACE_ONLYSIMPLE_OPTIMIZATIONSADVANCED_OPTIMIZATIONSWHITESPACE_ONLYremoves comments, trim line breaks and unnecessary spaces. The output code is identical to the source JavaScript.SIMPLE_OPTIMIZATIONSalso renames local variable and function parameters.ADVANCED_OPTIMIZATIONSis the most aggresive, besides the optimization in the above two levels, it also does:For the give example:
WHITESPACE_ONLYresult is :SIMPLE_OPTIMIZATIONSresult is:ADVANCED_OPTIMIZATIONSresult is:I think the
SIMPLE_OPTIMIZATIONSandADVANCED_OPTIMIZATIONSmeet your need.