What is minified JavaScript?

Minification (very often just minify, and sometimes also minimisation or minimization), is the practice of removing unnecessary characters from code to reduce its size thereby improving load times. When code is minified all comments are removed, as well as unneeded white space characters (space, newline, and tab). In the case of JavaScript, this improves response time performance because the size of the downloaded file is reduced.

In computer programming languages and especially JavaScript, it is the process of removing all unnecessary characters from source code, without changing its functionality. These unnecessary characters usually include white space characters, new line characters, comments and sometimes block delimiters; which are used to add readability to the code, but are not required for it to execute.

Minified source code is specially useful for interpreted languages deployed and transmitted on the Internet (such as JavaScript), because it reduces the amount of data that needs to be transferred. Minified source code may also be used as a kind of obfuscation.

Minified source code is also very useful for HTML & CSS code. All white space in HTML & css is reduced to only one space on the surface of a web page, so it's often quite possible to halve the size of a web page, by removing all excessive white space.

A good minifying software is expected to reduce size to about 30-40% of original source code.

Tools for minifying code

popular tools for minifying JavaScript code are

  1. JSMin : The JavaScript minifier. A tool for minifying JavaScript source code.
  2. YUI Compressor : Compress your JavaScript and CSS using this Java application from the Yahoo! team.
  3. Minify : A PHP library that combines, minifies, and caches JavaScript and CSS files on the fly.
  4. CSS Compressor : Free online tool for minifying CSS code.
  5. Online JavaScript minifier tool : An interface allowing you to upload your javascript files to get the minified version on submission.
  6. Minify JavaScript Online : Compress your JavaScript online with the JSMin algorithm (direct copy/paste into textarea).
  7. vlid : yet another free, online & simple minifying tool.

Important Links