Web development

Minification

Minification is removing unnecessary characters, such as spaces, line breaks and comments, from HTML, CSS and JavaScript files to make them smaller and faster to download.

Code written by developers includes spacing and comments for readability. Browsers do not need them, so minification strips them out before files go live.

In more detail

Minifiers also shorten variable names in JavaScript and combine rules in CSS. Modern build tools, such as Vite and esbuild, which frameworks like Astro use, minify automatically. Minification is usually combined with compression (gzip or Brotli) at the server or CDN, which shrinks files further. Removing unused code, known as tree shaking, and avoiding unnecessary libraries often save more than minification alone.

Why it matters

Smaller files download and parse faster, especially on mobile networks, improving page speed and Core Web Vitals.

Example

A site's 600 KB of unminified JavaScript shrinks to 180 KB after minification and Brotli compression, and removing an unused animation library cuts it to 90 KB. Interaction responsiveness improves noticeably.

FAQ

Minification: quick answers

Does minification change how code works?

No. It only removes characters that do not affect behaviour.

Is minification enough for good performance?

It helps, but removing unused code and loading scripts efficiently usually matters more.

Free audit

Find out where you stand in search and AI answers.

Get a free audit of your SEO, AI visibility and email setup. We send a short, specific report with the three changes that would move the needle most.