Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request --min-gain 1024 #79

Open
micheartin opened this issue Apr 20, 2021 · 0 comments
Open

Request --min-gain 1024 #79

micheartin opened this issue Apr 20, 2021 · 0 comments
Milestone

Comments

@micheartin
Copy link
Contributor

micheartin commented Apr 20, 2021

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 to 0.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.8 excludes 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.8 keeps 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}:

  1. --min-gain 1 (1 byte) is the same as --remove-larger
  2. --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.

@micheartin micheartin changed the title Request option --min-gain 1024 Request --min-gain 1024 Apr 20, 2021
@gios gios added this to the 4.x.x milestone Apr 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants