Compress static files with Brotli and Gzip using maximum compression. This greatly reduces file size. Which means files can download much faster. For more background read our blog post on static site implosion with Brotli and Gzip.
All dependencies needed to run the tests are pre-configured in package.json
. You just need to install these:
npm install
Note: it's smart to update to the latest versions of these dependencies.
Adjust the inputDir
and outputDir
in scripts/compress.js
(both default to dist/
).
Compress all files in inputDir
and write to outputDir
:
npm run compress
Note: This setup contains an example file in dist/examples/
.
As this setup uses the inputDir
as the outputDir
the compressed files are placed right next to the original.
You'll need to configure your server to serve the precompressed files when available. In addition you can enable on-the-fly compression of dynamic assets.