Text Compression
Compressing text-based files like HTML, CSS and JavaScript with Gzip or Brotli before sending them, so they transfer over the network faster.
Definition
Text compression is the practice of compressing text-based resources — such as HTML, CSS and JavaScript — with algorithms like Gzip or Brotli before the server sends them, so they transfer in fewer bytes.
Compression algorithms find repeated patterns in a file and encode them more compactly; the browser decompresses the file on arrival. Browsers advertise the formats they support through the Accept-Encoding request header, and the server responds with a compressed payload and a Content-Encoding header. For text assets this can cut transfer size substantially, reducing load time. Already-compressed formats like images are not compressed further this way.
Examples
Enabling Brotli
A server is configured to send JavaScript bundles with Brotli compression. A 300 KB bundle transfers as roughly 60 KB, and the browser decompresses it before running the code.
Content-Encoding
A browser sends `Accept-Encoding: gzip, br`; the server replies with `Content-Encoding: br`, indicating the CSS was compressed with Brotli.
Sources
Related terms
- Page SpeedHow quickly a web page loads and becomes interactive, measured by metrics such as Largest Contentful Paint, Interaction to Next Paint, and Time to First Byte.
- MinificationThe process of removing unnecessary characters from code such as comments and whitespace to reduce file size without changing behaviour.
- Render-Blocking ResourcesResources — typically CSS and synchronous JavaScript — the browser must fetch and parse before it can paint the first frame of a page.
Where QueryCatch uses this
Last updated: 07/07/2026