3. 2. White spaces . 3) strip white spaces 359Kb -> 290Kb(-69Kb)->239Kb(-51Kb)
4. 3. Variable names var bVariable , hVariable ... oVariable ; (a=Array, b=Boolean, c=Class, etc. ) 4) find all names of variables 5) sort list on amount of occurances 6) replace with {a..z}, {a...z}{a...z} 359Kb -> 290Kb(-69Kb)->239Kb(-51Kb)->138Kb(-101Kb)
5. 4. Object Members and String Values oObject .member = function() {...}; var sValue = "stringvalue" ; 7) find all members and strings 8) sort list on amount of occurences 9) put unique values into " _ " JavaScript array 10) replace oObject .member with oObject [_[N]] 11) replace "stringvalue" with _[N] 359Kb -> 290Kb(-69Kb)->239Kb(-51Kb)->138Kb(-101Kb)->128Kb(-10Kb)
6. 5. JavaScript Keywords/Operators/Constants function fTest ( bValue, sTest ) { for ( var nIndex = 0; nIndex < 10; nIndex ++ ) if ( bValue == true || sTest == "test" ) break ; } 12) create dictionary with keywords 13) encode keywords 13) replace keywords in code with decoded ones 14) wrap code with decoder 15) in decoder restore dictionary and code 16) evaluate code with Function constructor 359Kb -> 290Kb(-69Kb)->239Kb(-51Kb)->138Kb(-101Kb)->128Kb(-10Kb)->111Kb(-17Kb)
8. Appendix B: No title Original code without comments and spaces zip: 239Kb->46Kb Obfuscated/minified code zip: 111Kb->39Kb - 7Kb saved! - Code unreadable and fun!