static: Pre-compress with zopfli, for better compression.

Zopfli[^1] performs very good, but time-intensive, zlib compression.
It is hence only suitable for pre-compressing objects, not on-the-fly
compression.

Use a webpack plugin to write pre-compressed versions of JS and CSS
assets using Zopfli, and configure nginx to serve those assets when
`Accept-Encoding: gzip` is provided.

This reduces the size of the JS and CSS assets on initial pageload
from 1422872 bytes to 1108267 bytes, or about a 22% savings.

[^1]: https://github.com/google/zopfli
This commit is contained in:
Alex Vandiver
2024-07-31 22:10:40 +00:00
committed by Tim Abbott
parent b89d47a147
commit 2840e68548
5 changed files with 38 additions and 1 deletions

View File

@@ -8,6 +8,7 @@
"@babel/register": "^7.6.2",
"@fontsource-variable/open-sans": "^5.0.9",
"@formatjs/intl": "^2.0.0",
"@gfx/zopfli": "^1.0.15",
"@giphy/js-components": "^5.13.0",
"@giphy/js-fetch-api": "^5.6.0",
"@koa/bodyparser": "^5.0.0",
@@ -25,6 +26,7 @@
"clean-css": "^5.1.0",
"clipboard": "^2.0.4",
"colord": "^2.9.3",
"compression-webpack-plugin": "^11.1.0",
"core-js": "^3.37.0",
"css-loader": "^7.1.1",
"css-minimizer-webpack-plugin": "^7.0.0",