Compressing your WordPress site’s files is a great way to shrink your page sizes, speed up your site and improve your Core Web Vitals performance.
For a long time (since the 90s), GZIP compression has been the gold standard for web compression. But it’s not the only compression game in town – Brotli is a newer, Google-backed compression method that was released in 2013 and is quickly picking up steam.
So when it comes to Brotli vs GZIP compression for your WordPress website, which one should you be using? More importantly, does that question actually matter, or is either compression method fine? Let’s find out!
In addition to comparing both methods, we’ll also show you how to use both Brotli and GZIP compression on your WordPress site.
Brotli vs GZIP Compression: What’s the Difference?
Both Brotli and GZIP are methods to compress your website’s files. So at a high-level, both Brotli and GZIP are quite similar with respect to their core purpose.
The difference, of course, is in how they go about compressing your site and how effective they are.
Before we compare performance benchmarks, though, let’s cover the basics of GZIP and Brotli.
GZIP’s initial release was all the way back in 1992.
Since the ’90s, GZIP has been the dominant format for web compression. It still retains that position today – according to W3Techs, 78.6% of websites use GZIP compression at some level.
GZIP is based on the DEFLATE algorithm and, while people usually just refer to it as a single compression tool, there are actually different “levels” of GZIP compression.
In total, GZIP has nine quality levels that balance compression level vs speed:
- Level 1 – small file savings, but very fast compression speed.
- Level 9 – maximum file size savings, but comparatively slow compression speed.
All major browsers support GZIP and most web hosts also support GZIP out of the box.
Compared to GZIP, Brotli is much younger. It was initially released in 2013 by software engineers from Google, though it didn’t focus on HTTP compression until 2015.
While it took some time for adoption, Brotli is now supported by all major web browsers in 2019.
Like GZIP, Brotli also has different compression levels. In total, it has eleven different levels that follow a similar pattern as GZIP:
- Level 1 – small file savings, but very fast compression speed.
- Level 11 – maximum file size savings, but comparatively slow compression speed.
Brotli vs GZIP Benchmarks: Which Performs Better?
Ok – now for the important question:
Brotli vs GZIP compression – which performs better?
Here, we’ll turn to some public benchmark tests.
Before we dig into the data, it’s important to understand that there are multiple parts to compression and web performance:
- Compression ratio – this is how big the file size savings are. E.g. a 2 MB file compressed to 1 MB.
- Compression speed – this is how quickly it takes to compress and decompress the file. This is especially important for dynamic content that you need to compress “on-the-fly”.
Let’s look at the data…
First, there’s this benchmark from content-delivery giant Akamai.
- Median GZIP savings was 78%
- Median Brotli savings was 82%
Higher is better.
More specifically, Akamai found that Brotli was:
- 21% better at compressing HTML
- 17% better at compressing CSS
Those are the median numbers from Akamai’s tests.
But remember – compression is more than just smaller file sizes – it also matters how long it takes to perform the compression (AKA the compression speed).
In terms of compression speed, Akamai found that it matters which “level” you use. GZIP was faster at some levels, while Brotli performed faster at some levels.
In the end, Akamai concludes that “if you tweak the Brotli settings a little bit, the compression speeds can actually surpass the speeds of GZIP while still providing some significant savings”.
OpenCPU also ran their own benchmarks and found that:
- Brotli was superior in terms of the compression ratio
- GZIP was much faster at on-the-fly compression. It’s unclear how much they “tweaked” these settings
Does the Difference Matter?
The data is clear that Brotli offers a better compression ratio than GZIP. That is, it compresses your website “more” than GZIP.
However, remember that it’s not just about the compression ratio, it’s also about how long it takes to compress and decompress data. There, the difference isn’t quite as pronounced.
In general, the data seems to suggest that:
- Brotli is better at compressing static data because of its superior compression ratio
- GZIP is better at compressing dynamic data because of its often superior compression speed
Akamai also notes that, if you play around with the Brotli settings, you can get compression speeds that rival GZIP while also benefiting from a better compression ratio.
In general, though, if you’re just an average WordPress user, I don’t think the GZIP vs Brotli debate is something you really need to worry about.
It’s important to use some type of compression. But for your average run-of-the-mill WordPress website, you don’t need to stress about whether you’re using GZIP or Brotli.
Additionally, GZIP compression is much easier to use on WordPress because of its almost universal adoption, so it’s a good starting point for most WordPress users that will still get your site the benefits of compression.
How to Use GZIP Compression on WordPress
First off, if you’re using WP Rocket, your site is already benefiting from GZIP compression. WP Rocket automatically activates GZIP compression as soon as you activate the plugin – you don’t need to perform any manual actions.
If you’re not using WP Rocket yet, WP Rocket offers an easy way to get started with GZIP compression on WordPress, but it’s certainly not the only way.
You can also activate GZIP compression…
- Manually by adding a code snippet to your site’s .htaccess file
- Via a dedicated WordPress GZIP compression plugin
Enable GZIP Compression on WordPress via .htaccess
If your site uses the Apache webserver (which most WordPress hosts do), you can enable GZIP compression by adding the following code snippet to your site’s .htaccess file:
Enable GZIP Compression on WordPress via Plugin
Many WordPress caching and performance plugins include GZIP compression as part of their features. Again, that includes WP Rocket.
However, if you just want a plugin that’s laser-focused on GZIP compression, you can use the free Enable GZIP Compression plugin at WordPress.org. Once you install and activate the plugin, go to Settings → GZIP compression and click the Enable GZIP compression button:
How to Test GZIP Compression
Once you’ve enabled GZIP compression, you use Varvy’s GZIP compression tester to make sure it’s working:
How to Use Brotli Compression on WordPress
Using Brotli compression on your WordPress site is a little more complicated.
First off, if you want to enable Brotli compression at a server level, you’ll need to pick a host that supports Brotli (or gives you server access to install the Brotli library yourself).
While almost every single host supports GZIP out of the box, finding a WordPress host that supports Brotli on shared or managed plans is much less common.
Thankfully, there’s another option that will work for all WordPress sites:
If you’re willing to use the Cloudflare CDN service, you can enable Brotli compression with the click of a button. Just look for the Brotli setting in the Speed tab of your site’s Cloudflare dashboard:
WP Rocket also has a dedicated Cloudflare integration that makes it super easy to get up and running.
How to Test Brotli Compression
Once you’ve connected your WordPress site to Cloudflare and enabled Brotli compression, you can test if it’s working by using KeyCDN’s Brotli test tool.
Brotli vs GZIP: Pick the One That’s Right For You
Both GZIP and Brotli help you compress your WordPress website’s files. GZIP is the older and more popular of the two, while Brotli is newer but picking up steam.
While Brotli does seem to outperform GZIP in some benchmarks, especially when you play around with its configuration, GZIP is probably still a better starting point for most WordPress users because:
- It’s much easier to use with WordPress because almost every host supports GZIP out of the box.
- It’s still quite competitive in benchmarks and will have a positive effect on your site’s page load times.
If you have the ability to manually install Brotli on your server, or if you’re willing to use Cloudflare, Brotli is certainly still a good option. It’s just not as popular, and therefore not as easy to use with WordPress.