Back to Web Design Glossary

What Is Data Compression?

Compression is the process of encoding data using fewer bits, making files smaller so they use less storage space and transfer faster. When enabled on a web server, HTTP compression shrinks text responses like HTML, CSS, and JavaScript by up to 70%, so pages load faster and use less bandwidth. Lossless compression is reversible; lossy compression permanently discards detail.

More About Compression

Lossy vs. lossless compression

Every compression method is one of two kinds, and the difference decides where to use each.

  • Lossless compression restores the original file byte for byte. PNG and GIF images use it, and web servers apply it (as gzip or Brotli) to HTML, CSS, and JavaScript. Use it for text, code, logos, and screenshots, where every character or pixel matters.
  • Lossy compression permanently discards detail people are unlikely to notice, which produces much smaller files. JPEG images and web video use it, and WebP supports both modes. Use it for photos and video, and keep your originals, because the discarded detail can't be recovered.

Lossy compression usually achieves far better ratios than lossless, which is why the formats built for photos and video rely on it. Our guide to optimizing images for the modern web walks through picking formats and tools.

How compression works on a website

Web compression is a negotiation between browser and server. The browser lists the algorithms it accepts in its Accept-Encoding request header. The server picks one it's also configured to use, compresses the response, and labels it with a Content-Encoding header. The browser decompresses the file on arrival, automatically. MDN (checked July 2026) calls gzip the most common algorithm and Brotli the newer challenger; its Content-Encoding reference also registers Zstandard (zstd) for servers and browsers that support it.

Flow diagram of HTTP compression negotiation: the browser sends a request whose Accept-Encoding header lists the algorithms it accepts, the server picks one it supports and compresses the response, the response returns with a Content-Encoding header naming the algorithm, and the browser decompresses the file automatically on arrival.

Modern browsers broadly support HTTP compression, but servers vary: some enable it out of the box, and many need explicit configuration. To check yours, load your site with your browser's dev tools open and look for a Content-Encoding header on the Network tab. If it's missing on managed hosting, your host's control panel or a performance plugin can usually turn it on. If you administer the server yourself, enable a content-encoding module, such as Apache's mod_deflate or nginx's gzip module, or put a compressing proxy or CDN in front. Our guide to speeding up WordPress covers the rest of the performance checklist.

How much compression saves

HTTP compression can cut some text documents' transfer size by up to 70%, according to MDN's Compression in HTTP guide (as of July 2026). Text compresses that well because it's highly redundant; MDN puts typical text redundancy at up to 60%, and that redundancy is exactly what compression removes. The payoff is less bandwidth used on every visit and a shorter page load time, which is why enabling compression is one of the first steps toward better website performance.

Compression vs. minification

Minification is not compression. It permanently edits the file itself, stripping whitespace, comments, and long variable names out of your code, and that smaller file is what gets stored and served. Lossless HTTP compression encodes the response for transfer, and the browser restores it exactly. The two stack rather than compete: a plugin like WP Rocket minifies your files first, then the server compresses the smaller result with gzip or Brotli before sending it.

Frequently Asked Questions

Both compress text over HTTP. Gzip is the long-standing default; Brotli compresses text further but more slowly, per MDN. Newer servers may also offer Zstandard. The server picks an algorithm the visitor's browser accepts and the server is configured to use, so you don't choose per visitor.
No. Formats that are already compressed, like JPEG images, MP4 video, and ZIP archives, gain almost nothing from a second pass, and the algorithm's overhead can actually make the file larger. Serve those files as they are, and don't gzip your images.
Compression trades CPU time for smaller transfers. At moderate settings, that trade is usually worth it. Busy sites can precompress or cache static files and avoid maximum compression levels, which cost the most CPU per request. After enabling compression, watch your server's CPU use and response times.
Special Offer

Powerful WordPress Hosting

Reliable, lightning-fast hosting solutions specifically optimized for WordPress. Find the perfect plan for you by clicking below.

WordPress Hosting Plans