Minify JavaScript code by removing whitespace, comments, and shortening variable names. Reduce JS file size for faster script loading and improved website performance.
JavaScript minification removes unnecessary characters from JS code and can also shorten variable and function names (mangling). This process reduces file size by 40-60% on average, significantly improving script download and parse times. Since JavaScript is often the largest resource on a page, minification has a major impact on performance.
Size Reduction = (Original Size - Minified Size) / Original Size × 100%JS minification reduces size through: removing whitespace and comments, shortening local variable names (mangling), removing unreachable code (dead code elimination), optimizing expressions, and merging declarations. Advanced minifiers like Terser can achieve 40-60% reduction.
| Input | Output |
|---|---|
| function calculateArea(width, height) { // Calculate the area const area = width * height; return area; } | function calculateArea(a,b){return a*b} |
| const greeting = "Hello"; console.log(greeting); | const a="Hello";console.log(a) |
| if (x === true) { return "yes"; } else { return "no"; } | return x===!0?"yes":"no" |