Is it possible to use brotli compression in React?

4.6k Views Asked by At

My webpack bundle is quite heavy (2.3mb). I recently read articles about brotli compression, but all of them talk about a classic set up with js files served by a server. So the compression happens in the backend. My question may be stupid, but is it possible to apply such a compression to my webpack chunks in a React app (I already use Terser plugin default configuration)?

1

There are 1 best solutions below

2
On

This kind of compression should be handled by the server in realtime in my opinion but you can build brotli compression of your files via webpack plugins as well please check out:

https://webpack.js.org/plugins/compression-webpack-plugin/#using-brotli

please note that only build files will have brotli compression here not API calls and other assets.