Gzip
Definition
A compression method that makes web files significantly smaller for faster transfer. Reduces HTML, CSS, and JavaScript by 70-90%.
What is Gzip?
Gzip is a file compression algorithm widely used on the web. It compresses text-based files (HTML, CSS, JavaScript) before the server sends them, then browsers decompress them automatically. The result: dramatically smaller file transfers and faster page loads.
A 500KB JavaScript file might become 100KB with Gzip – 80% less data to download.
How Gzip Works
- Browser requests a page, indicating it accepts compressed content
- Server compresses the response using Gzip
- Compressed data travels over the network
- Browser decompresses and uses the content
This happens transparently. Users don't know it's happening – they just experience faster loading.
Gzip Performance
| Content Type | Typical Compression |
|---|---|
| HTML | 70-90% reduction |
| CSS | 80-90% reduction |
| JavaScript | 70-85% reduction |
| JSON | 80-95% reduction |
| Images | Already compressed – no benefit |
Checking If Gzip Is Enabled
Google PageSpeed Insights
Run your site through PageSpeed. It flags if text compression is missing.
Browser Developer Tools
In Chrome: Network tab > click a file > check "Content-Encoding" header. Should show "gzip" or "br" (Brotli).
Online Tools
Sites like GIDNetwork's Gzip test check compression status.
Enabling Gzip
Most modern hosting enables Gzip by default. If not:
Apache (.htaccess)
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/css application/javascript
</IfModule>
Nginx
gzip on;
gzip_types text/html text/css application/javascript;
CDNs
Cloudflare, CloudFront, and similar services compress automatically.
Gzip vs Brotli
Brotli is a newer algorithm offering 15-25% better compression. Most modern setups use Brotli for supporting browsers and fall back to Gzip for older ones.