Public BetaVitalSentinel is now live! Read the announcement
Performance

What is Minification?

The process of removing unnecessary characters from code without changing its functionality, reducing file size for faster downloads.

Minification removes whitespace, comments, and shortens variable names in CSS, JavaScript, and HTML files. This reduces file size without affecting functionality.

What minification removes

  • Whitespace and line breaks
  • Code comments
  • Unused code (dead code)
  • Long variable names (renamed)
  • Semicolons (where optional)

Before and after example

// Before minification
function calculateTotal(items) {
  let total = 0;
  for (const item of items) {
    total += item.price;
  }
  return total;
}

// After minification
function calculateTotal(t){let e=0;for(const l of t)e+=l.price;return e}

Minification tools

  • JavaScript: Terser, UglifyJS, esbuild
  • CSS: cssnano, clean-css
  • HTML: html-minifier

Minification in build tools

Most bundlers include minification:

  • Webpack (TerserPlugin)
  • Vite (built-in)
  • Next.js (automatic)

Impact on performance

Minification typically reduces file sizes by 30-50%, improving:

  • Download time
  • Parse time
  • Time to First Byte

Monitor your website performance

VitalSentinel tracks Core Web Vitals and performance metrics to help you stay ahead of issues.