The javacript compressor now supports real compression for even better compression ratios! You can still get the same results you were getting previously by checking the 'Crunch Only' option.
To do this it goes runs through the following steps.
Removing the comments is also done with regular expressions and the String replace function. 2 regular expressions are required, one for single line comments denoted by 2 forward slashes (//), another for multiline comments surrounded by a forward slash star pair (/*...*/).
Local variables are then identified as anything within the function preceded with the var keyword. Again a regular expression is constructed and used to replace all instaces of the parameter with a unique single character variable name.
All whitespace in the script is removed using the String replace function and a regular expression.
The reserved words stored earlier are put back into the script in the positions marked by the identifier they were replaced with.
The strings stored earlier are put back into the script in the positions marked by the identifier they were replaced with.