Overview

In web development, compression is used at multiple levels to speed up the delivery of assets. It can be applied to text-based resources (HTML, CSS, JS) and binary resources (images, videos, fonts).

Types of Compression

  • Lossless: Reduces file size without losing any data (e.g., Gzip, Brotli, PNG). The original data can be perfectly reconstructed.
  • Lossy: Reduces file size by permanently removing less important information (e.g., JPEG, AVIF, MP3). This achieves much higher compression ratios but with some loss in quality.

Server-Side Compression

Web servers like Nginx and Apache can be configured to automatically compress text-based responses before sending them to the browser, significantly reducing bandwidth usage.

Related Terms