What Is Minification in Web Development?

Minification removes unnecessary characters from source code — whitespace, comments, and sometimes shortening variable names — without changing its behavior,...

Published October 7, 2026

Minification removes whitespace, comments and shortens names in CSS, JavaScript and HTML to reduce file size without changing behaviour. Smaller files download and parse faster.

The concept

Minifiers (Terser, esbuild, cssnano) strip characters browsers do not need, rename local variables to single letters and simplify expressions.

Combined with gzip or Brotli compression, minification can cut transfer size dramatically. Source maps let you debug the original code.

Before and after

function add(first, second) { return first + second } → 52 B
function add(a,b){return a+b} → 29 B

Practical examples

Terser CLI

npx terser app.js -c -m -o app.min.js --source-map

CSS minify

npx cssnano styles.css styles.min.css

Bundlers do it by default

npm run build   # Next.js, Vite and webpack minify production builds

Try it here

Use this site's Code Minifier tool to minify JS, CSS or HTML in your browser.

https://devstudioonline.com/code-minifier

Common mistakes

  • Shipping unminified bundles to production.
  • Minifying without source maps and being unable to debug.
  • Relying on function names (fn.name) that mangling changes.

Key takeaways

  • Minify + compress for production.
  • It never changes behaviour.
  • Keep source maps.

FAQ

Minification vs obfuscation?

Minification targets size; obfuscation deliberately makes code hard to read.

Does it help SEO?

Faster pages help Core Web Vitals, indirectly helping rankings.

More JavaScript articles