Minify Javascript - Online Compressor / Packer

Related Tools


Javascript Minify Tool

Minifying Javascript takes the pretty, well formed JS code that you have written and removes the spacing, indentation, newlines, and comments. These arie not required for Javascript to run successfully. It also makes the Javascript more difficult to read when viewing the source.

Many developers will maintain a 'pretty' version, and upon deployment of their project run their scripts through a minification program. They also often combine their many script files into a single file.

A Minify Example

Before:

/* Show transparent overlay */
function pageOverlay() {
	$("#overlay").height($(window).height());
	$("#overlay").width($(window).width());
	$("#overlay").show();
}

After:

function pageOverlay(){$("#overlay").height($(window).height());$("#overlay").width($(window).width());$("#overlay").show();}

Why use Javascript Minifier?

The purpose of minifcation is to increase the speed of a website. Minimisation can make a script up to 20% smaller, resulting in a faster download time. Some developers will also use it to 'obfuscate' their code. This makes it difficult for the code to be read, thereby making it more difficult to reverse engineer or copy.

It is also common practice to combine all the Javascript files for a single website into one file. This has a number of benefits. It reduces the number of HTTP request that need to be made to get all the elements of a website. It also makes minification and gzip compression more effective.

External Links