also tend to over-parenthesize their expressions in order to make them more readable or to ensure that the intended precedence will unfold as expected. Extra parentheses can also be removed from the output. The danger is that this level of minification could
alter the semantics of the code if not done properly.
The next level of minification is to recognize the fact that local variables and functions are referenced only within a known scope, and can therefore have their identifiers shrunk down to shorter names. This is highly useful because developers can code with
longer, semantic names in their local functions and variables in order to increase readability and maintainability without having to penalize the client with large downloads. These modifications must be very carefully made because this level of change to the
sources is greatly increased. Scope chains must be respected or the code will cease to work properly, and global variables cannot be touched (since they may be referenced from other script files).
The next level is to analyze the code and recognize unreachable statements and functions, and unused variables. Eliminating these bytes from the download can go a long way to shrinking your page weight, without having to require constant manual reviews of the
code base. Again, this must be very carefully done to ensure that a function or variable really isn’t referenced.
The next level of minification is to analyze the usage of global variables and object properties, and to provide shortcuts in the code the replace the longer, repeatedly used constructs. For example, if the algorithm detects that a script repeated accesses
What can be replaced must also be carefully determined to make sure that the values and objects cached in the short local variables will remain the same value for the life of the variable. This level of minification is not for the faint of heart.
Microsoft Ajax Minifier by default will try to reduce the code as much as possible: removal of comments, whitespace, and unnecessary semicolons and curly-braces; renaming of local variables and functions to shorter names; and removal of unused or unnecessary
code. The -rename and –unused switches can be used to alter this default behavior.