HTML Minification: How Much Size Can You Actually Save?

●2 ●92 ●140
calendar_today • schedule3 min read

HTML minification is one of those optimisations that sounds boring until you see the numbers. Let's look at what it actually removes and what savings are realistic.

What minification removes

A standard HTML minifier targets four categories:

1. Whitespace between tags

``html

<!-- Before -->

Hello world

<!-- After -->

Hello world

`

Browsers collapse runs of whitespace when rendering anyway, so removing it from the source file doesn't change what users see.

2. HTML comments

`html
<!-- Before -->
<!-- Main navigation -->
...

<!-- After -->

`

Comments are stripped entirely in production builds.

3. Optional closing tags

The HTML spec allows certain closing tags to be omitted.

, , , , , , , are all optional. Removing them saves a few bytes on pages with heavy list or table markup. 4. Redundant attributes Attributes with default values can be dropped: type="text" on , type="text/javascript" on , type="text/css" on . Realistic size savings I ran minification on three real-world HTML pages and measured: | Page type | Original | Minified | Saved | |-----------|----------|----------|-------| | Simple blog post | 18 KB | 14.2 KB | 21% | | E-commerce product page | 42 KB | 32.5 KB | 23% | | Dashboard with tables | 95 KB | 71 KB | 25% | Typical savings range is 15–25%. Pages with more comments and indentation save more; minified-friendly templates save less. Minification stacks with compression The bigger win comes from combining minification with server-side compression: | Optimisation | A 50 KB HTML file | |---|---| | Raw | 50 KB | | gzip only | ~12 KB (76% reduction) | | Minified + gzip | ~9.5 KB (81% reduction) | | Minified + Brotli | ~8.5 KB (83% reduction) | Compression is much more powerful than minification alone — but they compound. Minification removes redundant characters; compression finds repeated patterns. Together they deliver the smallest possible transfer size. Most CDNs (Cloudflare, Fastly, AWS CloudFront) apply Brotli or gzip automatically. If yours does, minifying HTML is still worthwhile — it reduces the content the compressor has to work through and slightly improves compression ratio. Where minification helps most Single-page applications: The HTML shell is often tiny (a few KB), so the saving is negligible. Prioritise JS and CSS minification instead. Server-rendered pages: Large HTML pages with many components, conditionals, or loop-rendered tables benefit most. A product listing page with 100 items in a table can be 50–150 KB of HTML. Email HTML: Email clients don't use compression. Sending a 40 KB HTML email vs a 32 KB one adds up across millions of sends and affects inbox placement scoring for some providers. Static sites: Run HTML minification as the final build step. Hugo, Eleventy, and Jekyll all have minification plugins or post-processing steps. Inline JS and CSS: be careful Some minifiers (html-minifier-terser with minifyJS: true) also compress embedded and

Want more #webdev & #beginners deep dives?

Join 6,140+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

2 Comments

0 votes
1 vote

More Posts

Frameworks Are Institutional Memory

Ken W. Algerverified - Sep 17

Cisco's Amy Chang: A Model's "Passport" Doesn't Tell You Where It Actually Came From

Tom Smithverified - Aug 27

I’m a Senior Dev and I’ve Forgotten How to Think Without a Prompt

Karol Modelski - Mar 19

How I Built a React Portfolio in 7 Days That Landed ₹1.2L in Freelance Work

Dharanidharan - Feb 9

Core Web Vitals Benchmarks for Shopify Stores (2026 Data)

ApogeeWatcherverified - Sep 16
chevron_left
2.5k Points • 234 Badges
102Posts
0Comments
SnappyTools builds free, fast, browser-based tools for developers, writers, and designers. No signup... Show more

Related Jobs

View all jobs →

Commenters (This Week)

1 comment
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!