brotli: Compress Web Assets with -q 11
brotli compresses files to .br with quality levels 0 to 11, beating gzip on typical web text at -q 11, which is why build pipelines pre-compress static assets with it.
brotli is the format browsers accept alongside gzip. In CI you run brotli -q 11 over built JS, CSS, and HTML so the server can ship .br directly.
What it does
brotli compresses input with the Brotli algorithm and writes .br, keeping the source by default. Quality runs 0 (fast) to 11 (best); -q 11 is standard for pre-compressing static assets. brotli -d decompresses.
Common usage
brotli -q 11 app.js # -> app.js.br (keeps app.js)
brotli -q 11 -o style.css.br style.css
brotli -d payload.br # decompress
find dist -name '*.js' -exec brotli -q 11 {} \;Options
| Flag | What it does |
|---|---|
| -q <0..11> | Quality level; 11 is maximum |
| -d / --decompress | Decompress a .br file |
| -c / --stdout | Write to stdout |
| -o <file> | Explicit output path |
| -k / --keep | Keep the input file (default) |
| -f / --force | Overwrite existing output |
In CI
Pre-compress static assets in the build so the CDN or server serves .br to clients that send Accept-Encoding: br. Use -q 11 for release builds; it is slow but runs once. Install with apt-get install -y brotli or apk add brotli.
Common errors in CI
"brotli: corrupt input [<file>]" or "not valid Brotli compressed data" on decompress means the input is not a .br stream. "command not found" means the brotli package is missing. Passing -q above 11 errors; the valid range is 0 to 11.