Definition

Brotli is an open source, lossless data compression algorithm with a better compression density than gzip that reduces bandwidth consumption and helps content load faster.

Illustration of how the compression algorithm brotli works

Overview

Modern websites and web applications have become more demanding. Web pages now weigh more than ever and bandwidth consumption is at an all-time high. Mobile data traffic alone is expected to go from 6.2 Exabytes per month in 2016 to 30.6 Exabytes per month in 2020. These forecasts represent a need for new compression technology that minimizes bandwidth usage and keeps the web fast.

In comparison to gzip, brotli is around 20% more performant when it comes to compressing files such as HTML, CSS and JavaScript. In addition, Google, the creator of brotli, says that it’s 20-26% more performant than the other compression algorithm it made called zopfli. Because brotli was open-sourced by Google, the entire online community can benefit.

How Brotli Is Engineered

Brotli uses Huffman coding and a variant of the LZ77 algorithm which allows it to create a sliding window for backreferences. While gzip uses a fixed window of 32KB, Brotli uses a sliding window between 1KB and 16MB. This means that Brotli is able to optimize CWND and RWND and deliver larger, compressed files more efficiently. It also reuses entropy codes and adds a static dictionary that can be referenced from anywhere in the stream.

How Brotli Works

  1. A user accesses a website or web application running on a server that supports brotli
  2. The browser notifies the server about what kind of content it can decompress by using the Accept-Encoding header
  3. The server decides which kind of compressed content to deliver based on the compression algorithms contained in the request
  4. The server sends a Content-Encoding header to the browser, indicating the method used
  5. The browser decompresses the data before displaying it on the page

Conclusion

Because brotli is open source, it’s freely available as a server add-on to web hosting providers and content delivery networks (CDNs), as well as individuals and businesses that manage their own servers. Supporting this new compression algorithm doesn’t only save customers of hosting providers and CDNs on bandwidth costs; it also speeds up page load time across the web.

As new compression algorithms like brotli emerge, it becomes vital for server owners to adopt them. Doing so helps de-clutter and optimize content delivery over the Internet. However, browsers must support this technology as well. To see which browsers currently support brotli, check out this resource.