Expand my Community achievements bar.

Enable Better Compression of JS with Brotli

Avatar

Level 2

10/31/18

JS bundles in Launch are compressed with gzip, which saves many bytes. However, there is a new compression algorithm which can yield even better network (and thus user) performance: Brotli.

Brotli is supported by all modern browsers and improves compression of JS by 14% over gzip (see the Akami Blog entry linked later).

A sample showing possible compression levels is https://tools.paulcalvano.com/compression.php

Here we can see that Launch bundles are compressed at gzip level 6, a good compromise between server performance and compression ratio.

On my bundle, the gzip compression ratio of 3.56 captures most of the benefits of compression (maximum gzip compression level results in a ratio of 3.57, but with dramatic increases in CPU requirements to compress to this level).

However, Brotli can compress my bundle to 3.78 at the same level of compression, while also reducing server CPU time. (see Understanding Brotli's Potential - The Akamai Blog). For static js files (like all of Launch's JS bundles) maximum compression can be performed once at the origin (on building the bundle) and then a cached version of this highly compressed file can be served to clients.

Since Akamai already supports brotli, basic support should only be a configuration change. Browsers which don't support brotli will still be served gzip content, but for the remaining 85% of users (https://caniuse.com/#feat=brotli) faster, better loading of analytics code awaits.