When it comes to making web pages load faster, three techniques get mentioned frequently: minification, gzip compression, and Brotli compression. They're often confused with each other, but they do fundamentally different things and work best when combined.

Minification

Minification removes unnecessary characters from your source code without changing how it works. This includes:

A 50KB JavaScript file might minify to 25KB — a 50% reduction. The code still runs identically, but it downloads faster and parses faster in the browser.

Minification is a build-time operation. You minify your code once during deployment, and the minified version is what gets served to users. You never edit the minified version directly.

Gzip Compression

Gzip is a transport-level compression applied by the web server before sending the response. The browser receives the compressed file and decompresses it automatically. This happens on every request — the browser sends Accept-Encoding: gzip in its request headers, and the server responds with a gzipped body.

Gzip typically reduces file size by 60-80% on text files. A 25KB minified JavaScript file gzips to about 8KB. The key point: gzip works on the minified file, so the savings compound. Minification reduces 50KB to 25KB, then gzip reduces 25KB to 8KB — a total reduction of 84%.

Brotli Compression

Brotli is a newer compression algorithm that typically achieves 15-25% better compression than gzip for text files. It's supported by all modern browsers (Chrome, Firefox, Safari, Edge) but not by older browsers. Most CDN providers (including Cloudflare) support Brotli automatically.

For best results, serve Brotli to browsers that support it and fall back to gzip for older browsers. Your server or CDN should handle this automatically based on the Accept-Encoding header.

How They Stack

Original file:     50 KB
  ↓ Minification
Minified:         25 KB  (50% reduction)
  ↓ Gzip/Brotli
Transferred:       8 KB  (84% total reduction)

The browser receives 8KB, decompresses it to 25KB, and executes the minified code. The original 50KB source file never travels over the network.

What to Minify

Don't minify images, fonts, or binary files — they're already compressed, and minification won't help. Use appropriate image formats (WebP, AVIF) and compression tools instead.

Measuring the Impact

Use browser DevTools (Network tab) to see the actual transferred size versus the content size. The "Size" column shows what was transferred over the network (after compression), and the "Time" column shows how long it took. Compare before and after minification to see the real impact.

Tools like Lighthouse and PageSpeed Insights also report minification opportunities. If Lighthouse says "Minify JavaScript" with a potential savings, you have unminified code reaching production.

Common Pitfalls

Use the code minifier on this site to minify JavaScript, CSS, or JSON before deployment. The formatter can reverse the process when you need to read minified code. Both run entirely in your browser — no code is uploaded.