Book a call Free rebuild

Brotli

November 29, 2022 Updated November 16, 2026 2 min read

Performance glossaryBrotli is a compression format from Google that shrinks text files such as HTML, CSS, and JavaScript further than gzip. All modern browsers support it.

Brotli is a lossless compression format built for the web. A server compresses text responses such as HTML, CSS, JavaScript, JSON, and SVG with Brotli before sending them, and the browser decompresses them on arrival. Smaller files cross the network faster, which matters most on mobile connections.

Google engineers developed Brotli, first to compress WOFF2 web fonts and then as a general-purpose format released publicly during 2015. It was standardized as RFC 7932 in July 2016, and every modern browser supports it.

How it works

Brotli combines three techniques:

  • LZ77-style matching, which replaces repeated strings with short references to an earlier copy, as gzip does.
  • Huffman coding, which gives common symbols shorter codes.
  • Context modeling and a built-in dictionary of words and fragments common on the web, such as HTML tags and frequent English words. Because the browser already knows the dictionary, even short files with little internal repetition compress well.

The browser announces support in its Accept-Encoding request header, and the server replies with Content-Encoding: br. Browsers only offer Brotli over HTTPS.

Brotli vs gzip

At comparable settings, Brotli usually produces smaller text files than gzip, and browsers decompress both quickly. The trade-off is on the server: Brotli's quality levels run from 0 to 11, and the highest are slow to compress. The usual approach is to:

  • pre-compress static files such as CSS and JavaScript once, at a high level, when the site is built or deployed;
  • compress dynamic responses such as HTML pages on the fly, at a moderate level;
  • keep gzip as the fallback for any client that does not accept Brotli.

Neither format helps with JPEG, PNG, WebP, or AVIF images, video, or WOFF2 fonts, which are already compressed.

Brotli on a WordPress site

Compression happens on the web server or CDN, not in WordPress, so there is no WordPress setting for it. In practice:

  • A CDN such as Cloudflare sends Brotli to browsers that accept it, whatever the origin server does.
  • Managed hosts often have it enabled already; it is worth asking.
  • A self-managed server needs a module: Apache has mod_brotli, and nginx needs the separate ngx_brotli module. LiteSpeed supports Brotli as well.

How to check it is working

Open the browser's developer tools, go to the Network tab, reload the page, and select the HTML document or a stylesheet. A response header of content-encoding: br means Brotli is on. gzip means the fallback was used, and no header at all means the file arrived uncompressed.

Zstandard (zstd) is a newer format that some browsers and CDNs now support too, but Brotli and gzip remain the standard pair for compressing web text.

WP Services

WordPress services at revolutionary pricing.

Productized WordPress services, from builds to care, delivered by Seahawk and tracked in one app. For the WordPress lovers.