CalcSnippets Search
Web Performance 3 min read

Brotli vs Gzip Compression for Web Performance

Compare Brotli and gzip compression for websites, including text assets, CDN support, browser compatibility, compression levels, and practical performance gains.

Compression reduces transfer size

Brotli and gzip are compression algorithms used to reduce the size of text-based web assets such as HTML, CSS, JavaScript, SVG, and JSON. Smaller files usually transfer faster, especially on slower networks or long-distance connections. For global websites, compression is a basic performance requirement because users may arrive from many regions and devices.

Compression does not make every file smaller. Images, videos, and already-compressed formats usually need different optimization strategies. Applying gzip or Brotli to a JPEG or WebP image usually does little. Compression is most useful for text assets.

Gzip is universal and reliable

Gzip has been supported for many years and works across essentially all modern browsers and servers. It is a safe baseline. If a site serves text assets without gzip, it is leaving easy performance gains on the table. Most hosting platforms and CDNs can enable gzip with minimal configuration.

Gzip compression levels can be adjusted. Higher levels may reduce file size slightly more but require more CPU. For dynamic responses, extremely high compression may not be worth the cost. For precompressed static assets, higher levels can be acceptable because compression happens during build time rather than per request.

Brotli often compresses text better

Brotli is a newer compression algorithm that often produces smaller text files than gzip, especially for JavaScript, CSS, and HTML. Modern browsers support Brotli over HTTPS, and many CDNs can serve Brotli automatically when the browser sends the right Accept-Encoding header.

The practical benefit depends on the site. A content-heavy site with modest JavaScript may see smaller gains than a JavaScript-heavy app, but HTML and CSS can still benefit. The best approach is to measure real transfer sizes before and after enabling Brotli.

  • Enable gzip as the baseline for text assets.
  • Use Brotli when the CDN or server supports it reliably.
  • Precompress static assets during builds when possible.
  • Do not rely on text compression to fix oversized images or heavy scripts.

Precompression helps static sites

Static websites can generate compressed versions of assets during the build process. The server or CDN can then serve the precompressed file directly. This avoids runtime CPU work and allows stronger compression settings. Some platforms handle this automatically. Others require configuration.

When using precompressed assets, verify that headers are correct. The response should include the right Content-Encoding and content type. Serving a Brotli file without the proper header will break the page. Also ensure fallback gzip or uncompressed responses exist for clients that do not support Brotli.

Compression is one layer of performance

Brotli can beat gzip on size, but compression should not distract from bigger issues. Removing unused JavaScript, optimizing images, caching assets, improving server response time, and reducing third-party scripts may produce larger gains. Compression makes necessary files cheaper to transfer; it does not decide whether those files are necessary.

For SEO and user experience, faster transfer helps pages become readable sooner. A global website should enable modern compression, test from multiple regions, and monitor real user performance. Brotli and gzip are not exciting, but they are dependable tools in a serious performance stack.

Keep reading

Related guides