What Is Compression?
Compression in the context of web performance refers to encoding files into a smaller form before they are sent over the network. When a browser requests a web page, the server can compress the HTML, CSS, and JavaScript files on the fly. The browser receives the smaller, compressed version, decompresses it almost instantly using built-in capabilities, and renders the page. This entire process happens transparently and can cut text-based file sizes by 60 to 85 percent.
There are two categories of compression relevant to websites. The first is server-side text compression, where algorithms such as GZIP and Brotli shrink HTML, CSS, JavaScript, JSON, and XML files during transmission. The second is image compression, which reduces the size of photographs and graphics either losslessly, by removing metadata, or lossily, by reducing colour depth and detail to levels that are imperceptible to most viewers. Both types serve the same ultimate goal: delivering the same visual experience with fewer bytes transferred.
Google's PageSpeed Insights tool specifically checks for the presence of text compression and flags it as a high-priority fix when absent. For South African businesses hosting sites on shared or budget hosting, this setting is sometimes disabled by default and must be manually enabled in the server configuration or via a plugin. Enabling server-side compression is one of the most impactful, lowest-effort performance improvements available, often reducing total page transfer size by several hundred kilobytes with a single configuration change.
Modern hosting stacks and content delivery networks (CDNs) such as Cloudflare apply Brotli compression automatically. Brotli, developed by Google, achieves approximately 15 to 20 percent better compression ratios than GZIP for web assets. For WordPress sites, caching plugins such as WP Rocket and LiteSpeed Cache include compression modules that activate with a single toggle, requiring no server access.
Compression In Practice
A retail client in Johannesburg running a WordPress WooCommerce store recently improved their Google PageSpeed score from 42 to 79 by enabling Brotli compression through their Cloudflare plan alongside image optimisation. The total page size dropped from 3.8 MB to 1.1 MB. This translated to a measurable reduction in bounce rate, particularly among mobile visitors on Telkom and MTN connections who were abandoning the page before it finished loading.
For businesses using Apache-based hosting, compression is enabled by adding a few lines to the .htaccess file to activate mod_deflate. On Nginx servers, the gzip on; directive in the server configuration achieves the same result. If you are unsure whether compression is active, tools such as Google PageSpeed Insights, GTmetrix, or Check GZIP Compression at gzip.io will tell you immediately. Compression works alongside lazy loading and browser caching to form the foundation of a fast, well-optimised website.
What compression is in web performance
Compression, in web performance, is the reduction of file sizes so that less data must be transferred and stored, making websites load faster and use less bandwidth. It applies in several contexts on a website. Text compression (such as GZIP or the newer Brotli) shrinks text-based files, HTML, CSS and JavaScript, when the server sends them to the browser, which decompresses them on arrival, substantially reducing the data transferred for these files. Image compression reduces the file size of images, either without any loss of quality (lossless) or by discarding some data for a smaller file (lossy), and choosing appropriate image formats and compression is one of the biggest performance levers, since images often make up much of a page's weight. Other assets, such as fonts and videos, can also be compressed or optimised. Compression matters greatly for web performance because transferring less data means pages load faster, especially on slower or mobile connections, and faster pages improve user experience and Core Web Vitals, which support both engagement and SEO. Understanding compression matters because it is one of the most effective, standard ways to speed up a website: by reducing the size of the files a page depends on, text, images and other assets, compression directly cuts load time, which is why enabling and applying it well is a basic part of website performance optimisation.
Types of compression and applying it
Applying compression well means using the right kind for each type of asset. For text-based files (HTML, CSS, JavaScript), server-level compression with GZIP or Brotli is the standard: it is enabled in the web server configuration and then compresses eligible files automatically for every visitor, with Brotli often achieving slightly better results than GZIP where supported, and GZIP as a universally-supported fallback. This text compression is a low-effort, high-value setting that should be on. For images, the distinction between lossless and lossy compression matters: lossless compression reduces file size without any loss of quality (useful where image fidelity must be preserved), while lossy compression achieves smaller files by discarding some visual data (acceptable for many photographs where a slight, often imperceptible, quality reduction is a fair trade for a much smaller file). Choosing modern, efficient image formats (such as WebP) and compressing images appropriately is one of the most impactful performance improvements, since images are often the heaviest part of a page. Importantly, text compression like GZIP and Brotli does not meaningfully shrink already-compressed files such as images and video, which are handled through their own formats and image compression instead, so the two are complementary. Alongside compression, related techniques, minification (removing unnecessary characters from code), caching, and a content delivery network, combine to make a site fast. For a South African website, where many users are on mobile and slower or metered connections, applying compression well, text compression enabled server-side, images in efficient formats and appropriately compressed, meaningfully reduces load times and data usage, improving experience, Core Web Vitals and SEO, which is why compression is a fundamental part of performance optimisation.
FAQ
What is the difference between lossless and lossy compression?
Lossless compression reduces file size without discarding any data, allowing perfect reconstruction of the original. GZIP uses lossless algorithms. Lossy compression discards some data to achieve smaller sizes, as JPEG and WebP do with images. For text-based assets like HTML and CSS, lossless algorithms are always used because data integrity is required.
How do I check if my website uses compression?
Open Chrome DevTools, go to the Network tab, and reload your page. Click any HTML, CSS, or JavaScript file and look under Response Headers for Content-Encoding: gzip or Content-Encoding: br. If neither appears, your server is not compressing text assets. Google PageSpeed Insights also flags missing compression as a high-priority issue.
How do you check if your website uses compression?
Page-speed tools such as Google PageSpeed Insights report whether text compression is enabled and flag uncompressed resources, and browser developer tools show the response headers (a content-encoding of gzip or br indicates GZIP or Brotli compression is active). These tools also highlight images that could be compressed further or served in more efficient formats, so running your site through one shows both whether text compression is on and where image compression could help.