What is Minification?
Minification, which is also known as minimisation or minimization, removes unnecessary characters from source code in computer programming languages such as JavaScript. This removal does not alter the functionality of the code. Examples of unnecessary characters are white spaces, new line characters, block delimiters (used to make the code more readable but not required for the computer’s use), and comments. Removing these reduces the amount of data the computer must transfer, and it may also be used as obfuscation — which is not to be confused with false cryptography. Minified code can be reversed with a pretty-printer, unlike the false cryptography. Programmers compete to minify their code more than their peers.
Minification is not data compression
Minification is not false cryptography – nor is it data compression. The minified code can be directly interpreted as is with no uncompression step needed, and the same interpreter can read the original and the minified sources.
History
The first tool to perform minification of any sort was JSMin, which removed whitespaces and comments. Douglas Crockford developed it in 2003, and it was followed by the YUI Compressor. Next, Google, in 2009, developed a Closure toolkit, which included a source mapping feature and Closure Inspector (a Firefox extension). Then Uglify JS appeared in 2010, developed by Mihai Bazon. In 2012, the program was rewritten to permit source map support.
Source Mapping and Minification
Source maps permit the display of unminified code from the minified code, using an optimized “mapping” between the two. Joseph Schorr built the first format as part of the Closure Inspector minification project. Updates such as versions 2 and 3 minimized the size of the map files.
Minification Tools
Some JavaScript optimizers, if not all, can minify and generate source maps. UglifyJS and Google’s Closure Compiler are among these.
Other online tools compress Cascading Style Sheets files. These include Microsoft Ajax Minifier and the Yahoo! YUI Compressor (also known as Pretty Diff). Then, a PowerShell script — “minifyPS” — shrinks PowerShell script code and JavaScript code. At BlimptonTech.com, you can find a free online tool to minify JS using UglifyJS. The tool can also combine multiple files.
How Minifying Code Affects the Web
By reducing the size of various files, web design Springfield MO firms quicken the page loading time and optimize file requests. Therefore, libraries and components of websites and Web applications have been developed.
Both Cascading Style Sheets and JavaScript resources allow minification — which allows them to function the same way while at the same time minimizing their file size quite a bit. Google has engineered the Closure Tools project in an effort to open source the tools they use many of their sites and web applications for use by the wider community in Web development. The Closure Compiler packs JavaScript into high-performance, compact code and can achieve aggressive global transformations to obtain advanced optimization and high compression. Other online libraries can also minify and optimize at various different levels.
In addition, some libraries merge multiple script files into one for client download, fostering a modular approach to development.
Ziproxy takes a novel approach to server-side minification. Ziproxy is a forwarding, compressing, non-caching HTTP proxy for traffic optimization. It both minifies and optimizes not only JavaScript and Cascading Style Sheets but also HTML. Then, too, it re-compresses pictures.
Modern web browsers and compatible web servers encode content to compress HTML and similar texts. Often, they compress these things into the gzip format.
The off-line CrunchMe tool provides an alternative to content encoding at least in the server-client layer. The tool CrunchMe creates self-extracting JavaScript programs by means of the DEFLATE compression algorithm.
JavaScript source maps make readable, debuggable code even after the combining and minifying processes.
As you can see, the trend to the minification of code has made the web faster, which benefits all users.