Request --min-gain 1024
The Brotli plugin for Webpack has an interesting minRatio parameter:
https://www.npmjs.com/package/brotli-webpack-plugin
minRatio: Only assets that compress better that this ratio are processed. Defaults to0.8.
We might add the option --min-ratio {value}. Note: the option --min-ratio 1 is the same as --remove-larger. This option applies to Gzip and to Brotli compressors.
However, we can also think further:
-
What about large files? Let's say 800 KB compressed file (original size is 1000 KB). The value
--min-ratio 0.8excludes this compressed file and the web server does not save 200 KB in local cache and bandwidth. -
What about tiny files? Let's say 79 bytes compressed file (original size is 100 bytes). The value
--min-ratio 0.8keeps this compressed file, but for a ridiculous gain of 21 bytes while consuming CPU for decompression on the client side. Thanks to the option--threshold 1000, we can prevent this corner case.
Therefore, I propose the option:
--min-gain {bytes}
This option can also avoid using the options --remove-larger and --threshold {xxx}:
-
--min-gain 1(1 byte) is the same as--remove-larger -
--min-gain 100, by design, excludes all files smaller than 100 bytes
To clarify this last point, --min-gain 100 also excludes some files larger than 100 bytes: the smaller files that are not well compressed. For example, a PNG file of 200 KB compressed to 101 KB will be excluded by --min-gain 100.
From my personal point of view, --min-gain is more interesting than --threshold. For example, --threshold 1000 may exclude an index.html (990 bytes) and its index.html.br (80 bytes). It looks better to use something like --min-gain 900.
Default value 0 (or -1) --> Disable this option.
It is up to you whether you implement --min-ratio or --min-gain or both. However, in my personal opinion, --min-gain is superior to --remove-larger, --threshold and --min-ratio. I think --min-ratio is not necessary if --min-gain is implemented.