Subscribe to our
weekly update
Sign up to receive our latest news via a mobile-friendly weekly email
In this post, we are going to talk about the Brotli Compression in comparison to other compression algorithms.
In the last blog, we discussed the different methods of compression and how it works. In this post, we are going to talk about the Brotli Compression in comparison to other compression algorithms.
Brotli Compression
Per rfc7932: Brotli is a lossless compressed data format that compresses data using a combination of the LZ77 algorithm and Huffman coding, with efficiency comparable to the best currently available general-purpose compression methods.
It’s maintained by Google and reduces bandwidth consumption and helps content load faster.
When it was developed in 2015, Brotli was used to compress fonts in the WOFF2(Web Open Font Format). With time, it’s popularity increased and now it’s even used for compressing/decompressing textual data. Brotli has a direct impact on page load times by reducing the page size and ultimately the bandwidth consumed.
This compression algorithm is now supported by many browsers as a new Accept-Encoding scheme that can be used to compress static web page assets.
Brotli: Browser Support
How to check if a Browser supports Brotli
most browsers that support Brotli compression advertise their ability to accept Brotli-compressed resources in the Accept-Encoding request header.
The Accept-Encoding Request HTTP header advertises which content encoding the browser understands. Using content negotiation, the server selects one of the proposals and informs the client of its choice with the Content-Encoding response header.
Here is a screenshot of HTTP Request-Response Headers captured from an instant test run for a website that supports Brotli compression.
The Instant test was run using Chrome Version: 53.
If you observe the Request Headers section, you will notice that the browser sent an HTTP Request advertising the Encoding schemes it supports.
accept-encoding: gzip, deflate, sdch, br
The Response Headers section clearly shows that the Web Server supports Brotli compression.
content-encoding:br
Google turned on the support for Brotli with its release of Chrome 51 in May 2016. Firefox had added support for Brotli as early as September 2015.
Since Brotli is another compression algorithm; like G-zip, let’s have a look at how each of the compression algorithms fair when tested for CSS, JS, and a JPEG resource.
So, let the comparisons begin. In this case, we are plotting the compression ratio comparing Brotli and G-Zip.
Compression Ratio
Compression Ratio is calculated using the formulae: Uncompressed Size/Compressed Size. A 10 MB uncompressed file compressed to 2 MB, the compression ratio will be 10/2 = 5. The lower the compression ratio, the better is the compression method.
In the screenshot above, we see Brotli reporting a better compression ratio for CSS and JavaScript file. G-zip and Brotli reported the same compression ratio (Compression ratio = 1) for a JPEG file of 4.23 MB.
Decompression Speed
A very important factor when it comes to benchmarking compression algorithms is decompression speed. How quickly browsers can decompress the compressed content at their end determines how strong the compression algorithm is.
When it comes to decompression speed as well, Brotli performed better than G-zip; reporting faster decompression times for the same JS, CSS, and JPEG files.
Compression Speed
Compression speed is an indicator of how quickly the algorithm could compress the content. The less time it takes to compress, the better the algorithm.
Looking at the compression ratio and decompression time metrics, we see that Brotli outperformed G-zip for all the resource types tested (JPEG Image, CSS, and JavaScript). However, the time taken for compression or compression speed shows us that Brotli took a lot more time than G-zip when compressing content. So, is this a problem?
I would say no. It is not advisable to judge or benchmark compression algorithms simply by comparing the bytes saved. Here’s why:
Future of Brotli
**All tests to compare the performance of G-Zip and Brotli were run using “R” on a computer with the following specifications:
_Processor: Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz, 2808 Mhz, 2 Core(s), 4 Logical Processor(s); RAM: 8.00 GB_