Installation and usage
Install using npm.
npm install brotli
If you want to use brotli in the browser, you should use Browserify to build it.
In node, or in browserify, you can load brotli in the standard way:
var brotli = ;
You can also require just the
decompress function or just the
compress function, which is useful for browserify builds.
For example, here's how you'd require just the
var decompress = ;
Decompresses the given buffer to produce the original input to the compressor.
outSize parameter is optional, and will be computed by the decompressor
if not provided. Inside a WOFF2 file, this can be computed from the WOFF2 directory.
// decode a buffer where the output size is knownbrotli;// decode a buffer where the output size is not knownbrotli;
brotli.compress(buffer, isText = false)
Compresses the given buffer. Pass optional parameters as the second argument.
// encode a buffer of binary databrotli;// encode some data with options (default options shown)brotli;