Minification is usually accomplished by parsing code, then outputting it again in a compressed format. This code is generally unreadable with the naked eye. This process usually removes all white spaces, comments, and new line characters. Many other optimizations can also be performed, such as removing block delimiters, inlining functions, using implicit conditionals, and rewriting local variables.
Several code constructs, however, prevent effective minification. The notorious `eval()` function can access any variables in its scope or global variables, and its contents cannot be known until runtime. Therefore, it’s impossible to perform renaming optimizations on certain sections of code that use `eval()`.
Because minification reduces the size of code, minified code requires less data to be transferred. As a result, it loads faster, helping to decrease page load times. Another advantage of code minification is that it can also be used to validate code. The minifier will alert you if your code is invalid, because invalid code obviously cannot be properly parsed and minified.