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.
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.