Short answer: Gzip compression shrinks the text files of a website, such as HTML, CSS and JavaScript, before they travel, and the browser unpacks them on arrival. Brotli does the same job and usually compresses more. Compress every text file, offer Brotli first with gzip as the fallback, and leave images and video alone.
How compression works
The browser and the server negotiate it, MDN explains. The browser sends an Accept-Encoding header listing the algorithms it supports, and the server picks one, compresses the response and names it in the Content-Encoding header.
A Vary: Accept-Encoding header in the response shows that this negotiation took place. MDN adds that, for some documents, compression cuts the size by up to 70%.
You don’t write any compression code yourself. MDN notes that browsers and servers already have it built in; your job is to make sure the server is set up for it.
The encodings you will see
| Encoding | Content-Encoding value | What to know |
|---|---|---|
| gzip | gzip | The most common one; every major browser supports it |
| Brotli | br | Usually smaller files than gzip; offer it first |
| Zstandard | zstd | A newer format listed by MDN |
| Deflate | deflate | An older format; Lighthouse counts it as compressed |
| No compression | identity | Always acceptable, even if a browser omits it |
From MDN and Chrome’s Lighthouse documentation, read November 5, 2026.
MDN calls gzip the most common algorithm and Brotli, written br, the newer challenger. Zstandard, written zstd, now appears on MDN’s list too.
What to compress, and what not
web.dev explains that gzip and Brotli work best on text: HTML, CSS and JavaScript. On larger files they often reach compression rates of 70 to 90%.
MDN recommends turning compression on for every file except those already compressed, like images, audio and video. Compressing a JPEG or a ZIP file again can even make it bigger.
web.dev adds that CDNs often compress text files automatically. Our CDN guide explains what else a CDN does.
Gzip or Brotli
Chrome’s Lighthouse documentation says to use Brotli when the browser supports it, because it can reduce files more than other algorithms. Keep gzip as the fallback, since every major browser supports it.
web.dev confirms that all modern browsers accept both and say so in their Accept-Encoding header. Offering both costs you nothing and serves every visitor.
Minify before you compress
Minification isn’t compression, web.dev explains. It removes the characters that only make code readable for people, and it is best done as part of your build.
The two work together: you minify the code and the response compresses what is left. Browser caching then saves repeat visitors from downloading it again.
How to check your site
web.dev’s quick test is to open Chrome DevTools, go to the Network panel and load a page. Click the page and each stylesheet or script, and read the Content-Encoding response header.
Lighthouse looks for text responses without a content-encoding of br, gzip or deflate. It ignores responses under 1.4 KiB and savings under 10%. That check now sits in the document request latency insight. Our PageSpeed Insights guide shows where to read it.
How to turn on compression
- Open your page with the browser’s developer tools on the Network tab.
- Read the Content-Encoding of the page, the stylesheets and the scripts.
- Turn on Brotli for text files, with gzip as the fallback.
- Leave images, video, audio and archives as they are.
- Minify CSS and JavaScript as part of your build.
- Check that responses send Vary: Accept-Encoding.
- Run PageSpeed Insights again and read the document request latency insight.
What our pages send
On November 5, 2026, we requested a guide and our pricing page, in both languages, the way a browser does: accepting Brotli and gzip. Every request answered, and each response said in its Content-Encoding how it was packed.
The pages themselves came with gzip. The English guide went from 107,138 bytes to 26,220 on the wire, and the pricing page from 98,475 to 23,316, about a quarter each time.
The files around them came with Brotli. The guide’s 17 stylesheets and 12 scripts add up to 526,497 bytes and traveled as 126,066. Only one stylesheet of 196 bytes went as is, far below the size Lighthouse would flag.
Before you publish
- The HTML arrives with gzip or br.
- Every stylesheet and script over 1.4 KiB arrives compressed.
- Brotli is offered to browsers that accept it.
- Images and video are not compressed a second time.
- CSS and JavaScript are minified before they ship.
- Responses include Vary: Accept-Encoding.
RememberText compresses well, images don’t. Pack the text files, offer Brotli with gzip as the fallback, and check the Content-Encoding of every response.
Our web design service builds pages that travel light, like the ones above.
Quick answers about gzip compression
What is gzip compression?
A way to shrink text files, such as HTML, CSS and JavaScript, before they travel. The browser asks for it in the Accept-Encoding header, and the response says it used gzip in Content-Encoding. The browser unpacks the file on arrival.
Is Brotli better than gzip?
Usually, for text. Chrome’s Lighthouse documentation says Brotli can reduce files more than other algorithms and recommends gzip as the fallback. All modern browsers accept both, according to web.dev, so you can offer both.
Should I compress images with gzip?
No. MDN recommends compression for all files except those already compressed, like images, audio and video. Compressing a JPEG or a ZIP file again can even make it bigger, MDN warns.
How do I know if my site uses gzip?
Open your browser’s developer tools, go to the Network tab and reload the page. Click the page and each stylesheet or script, and look for gzip or br in the Content-Encoding response header.
Does compression replace minification?
No, they work together. web.dev explains that minification removes the characters that only make code readable for people, while compression packs what is left. Minify as part of your build and let the response compress the result.
Sources
Read on November 5, 2026. MDN Web Docs: Compression in HTTP, Content-Encoding header and Accept-Encoding header. web.dev: Optimize the encoding and transfer size of text-based assets. Chrome for Developers: Enable text compression. Our case: our own pages, read on November 5, 2026.
