Performance fix
How to Enable Gzip / Brotli Compression
Compress text responses (HTML, CSS, JS) so they transfer much smaller.
Last updated by the SlapMyWeb team
- Difficulty
- Medium
- Impact
- High
- Time
- 15 min
Before
# nginx: no compression configuredAfter
# nginx
gzip on;
gzip_types text/css application/javascript application/json image/svg+xml;
brotli on;
brotli_types text/css application/javascript application/json;Text files like HTML, CSS and JavaScript compress very well, so serving them uncompressed wastes most of the bytes you send. Turn on Brotli or Gzip in your server or CDN, then confirm the response carries a content-encoding header. Transfer size drops sharply with no change to your code; web.dev reports rates often as high as 70 to 90 percent for larger text files.
Why it matters
Text-based files compress extremely well. Enabling Brotli or Gzip on the server cuts transfer size sharply with no change to your code (web.dev reports compression rates often as high as 70-90% for larger text files): one of the highest-leverage performance wins available.
How to fix it
Turn it on at the server
Enable Brotli (preferred) or Gzip in your web server / CDN for text MIME types.Verify the header
Check the response includescontent-encoding: br(orgzip) for HTML/CSS/JS.
The code
# nginx: no compression configured# nginx
gzip on;
gzip_types text/css application/javascript application/json image/svg+xml;
brotli on;
brotli_types text/css application/javascript application/json;On your platform
WordPress
Most managed hosts enable this by default. If not, a caching plugin or your host's control panel can turn on Gzip/Brotli.
Next.js
Next.js gzip-compresses by default; if you sit behind nginx/Cloudflare, enable Brotli there instead.
Sources
Check your site with our free tool
HTTP Header Checker
Related
What the terms mean
Check it free
More fixes
Performance
How to Minify Your CSS
Strip comments and whitespace from stylesheets to cut their size by 30-50%.
Performance
How to Minify Your JavaScript
Compress JS by removing comments, whitespace and shortening names: often a 40-60% reduction.
Performance
How to Lazy-Load Off-Screen Images
Defer images below the fold so they don't compete with the initial render.
Fixed that one.
Now find the rest.
A free audit puts every issue on your site into a fix plan, most urgent first, and links each one to its guide.
Run a free audit