CSS and JS minification is one of the first recommendations in any website speed optimization checklist. It sounds like a simple, almost free improvement: remove spaces and comments, and the site gets faster. That’s true, but only to an extent. Minification has a real, measurable effect—it’s just significantly smaller than it may seem compared with other speed factors. Let’s look at what it does technically and how much it contributes when honestly compared with the alternatives.
What minification actually is
Minification removes from the code everything that helps people read it but that the browser doesn’t need to execute it:
- spaces, indentation and line breaks;
- comments;
- unnecessarily long variable names (replaced with shorter ones in JS);
- sometimes, dead code that is never executed (though this is handled more by a more advanced process than by minification itself).
It’s important to distinguish between three different, though related, processes:
Minification is purely syntactic compression that doesn’t change the logic or structure of the code.
Bundling combines multiple files into one (or several) to reduce the number of network requests.
Tree-shaking removes code that has been imported but is not actually used in the final build (for example, unused functions from a library).
Modern build tools (Webpack, Vite, esbuild) perform all three steps together, so in practice it’s hard to tell them apart by their effects—but that’s also why minification is often credited with an effect that actually comes from all three processes combined.
How much minification itself really reduces file size
If you isolate the removal of spaces and comments from bundling and tree-shaking, the effect is more modest than is commonly believed:
- CSS minification usually reduces file size by 10-20% before compression;
- JS minification reduces it by 15-25%, depending on the style of the source code (code with long variable names and detailed comments compresses more noticeably).
That’s significant, but not decisive—especially given the next step.
What delivers most of the effect: compression during transfer
After minification, the file is still compressed during transfer (with Brotli or GZIP). And something interesting happens here: compression algorithms are excellent at handling repeating patterns—and spaces and indentation are among the most compressible data. As a result, the difference in final size between a minified file and an unminified file compressed with Brotli is often much smaller than the difference before compression.
That doesn’t mean minification is useless—a compressed, minified file is still smaller than a compressed, unminified one. But if compression isn’t configured on the server (which is itself a serious missed optimization), the effect of minification will seem overstated because you’re comparing it against the wrong baseline.
What to compare minification with in terms of real impact
If you rank performance factors by how much they actually improve loading speed, the picture usually looks like this:
- Brotli/GZIP compression — saves tens of percent in data transfer, with minimal implementation effort;
- HTTP/2 or HTTP/3 — enables resources to load in parallel without waiting in a queue, especially noticeable when there are many files;
- Lazy loading and code splitting — users don’t load what they can’t see on the screen right away;
- Removing unused code (tree-shaking) — especially critical for projects with large libraries that use only 5% of their functionality;
- Bundling — reduces the number of requests; its importance decreases with the move to HTTP/2 (where parallel loading is less costly);
- Minification — a consistent but modest contribution on top of everything listed above.
Minification is the “and so on” in this list, not the number one item. It’s worth doing every time because it’s almost free and has no downsides (except that debugging in production is a little more complicated without source maps)—but don’t expect a decisive breakthrough in Core Web Vitals from it.
When minification does make a noticeable difference
There are scenarios where its contribution is higher than average:
- CSS frameworks with large numbers of utility classes that aren’t properly configured for purge/tree-shaking—savings can be substantial here because unused classes are removed along with minification;
- Projects with very detailed comments and long names in the source code (generated code, old legacy projects);
- Environments without support for modern compression—on an old or poorly configured server, minification may be the only available way to reduce file size.
Practical checklist
- CSS and JS minification is enabled in the production build (through a code minifier or the build tool’s built-in features)
- Brotli or at least GZIP compression is configured on the server—without it, minification can’t deliver its full effect
- HTTP/2 or HTTP/3 is enabled
- Tree-shaking is configured—check that unused library code is actually removed from the final build
- Heavy components and images are loaded lazily, rather than all at once
- The effect of all changes is measured with a Web Vitals check, rather than estimated by eye
Conclusion
Minification is an essential, but not decisive, step in speed optimization. It should always be done: implementation costs are almost zero, and the effect—although modest—is consistently positive. But if the site is still slow after minification, the problem is almost certainly not minification itself; it’s a lack of server-side compression, an outdated protocol, or the unoptimized loading of heavy resources.
Check the actual effect of changes with the Web Vitals analysis tool—and first make sure that the more significant factors (compression, HTTP/2, lazy loading) are already in place before expecting miracles from minification alone.