Course contentsShow
← Web Development
Lesson 2133 of 2,98239. Network PerformanceFree lesson

Brotli Compression Algorithm

Learn about Brotli compression, its superior compression ratios over gzip, and modern browser support requirements.

Brotli Compression Algorithm

You'll learn: How Brotli compression delivers smaller file sizes than gzip and what you need to know about browser support.


Now that you understand gzip compression, it's time to meet its more efficient successor: Brotli. Developed by Google and released in 2015, Brotli is a compression algorithm specifically optimized for web content that consistently achieves 15-25% better compression ratios than gzip.

How Brotli Works Better

Think of gzip as packing a suitcase by rolling clothes tightly. Brotli does the same plus uses vacuum-sealed bags. It employs a larger dictionary of common patterns (especially for HTML, CSS, and JavaScript) and more sophisticated matching algorithms. This means your 100KB JavaScript bundle might compress to 30KB with gzip, but only 25KB with Brotli—saving precious bytes on every page load.

The Trade-off

Brotli's superior compression comes with a cost: it takes longer to compress on the server. However, since you typically compress static assets once during your build process (not on every request), this trade-off is usually worthwhile. Decompression speed in browsers is comparable to gzip.

Browser Support Requirements

Modern browser support is excellent: Chrome, Firefox, Safari, and Edge all support Brotli over HTTPS connections. However, there's a critical requirement: Brotli only works over HTTPS, not plain HTTP. This security restriction ensures the integrity of compressed content.

Your server can offer both encodings—sending Brotli to supporting browsers and falling back to gzip for older clients—based on the Accept-Encoding request header.

Key Takeaway: Brotli delivers 15-25% better compression than gzip for web assets, with excellent modern browser support, but requires HTTPS and is best used for pre-compressed static files rather than dynamic content.