From 0c64c5867b1b188fba482553c96b89aaed6d8158 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Wed, 30 Dec 2020 23:43:29 -0800 Subject: [PATCH] Use brotli_static with max brotli compression Compress with brotli ahead of time in CI, just like we do with zopfli for gzip_static Update hintrc to check for brotli compression. Update lighthouse config to throttle CPU some more since brotli decompression can be heavier. --- .build.yml | 3 ++- .hintrc | 12 +----------- .lighthouserc.yml | 2 +- Makefile | 5 ++++- README.md | 3 ++- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/.build.yml b/.build.yml index b33050a..8e626ef 100644 --- a/.build.yml +++ b/.build.yml @@ -2,7 +2,8 @@ image: alpine/edge packages: - rsync - - zopfli + - zopfli # for max compression with gzip_static + - brotli # for max compression with brotli_static - git # for Hugo's gitInfo - make - npm # for testing with lighthouse and webhint diff --git a/.hintrc b/.hintrc index 476e17c..1380d3e 100644 --- a/.hintrc +++ b/.hintrc @@ -34,17 +34,7 @@ } ], "doctype": "error", - "http-compression": [ - "warning", - { - "html": { - "brotli": false - }, - "resource": { - "brotli": false - } - } - ], + "http-compression": "error", "https-only": "error", "manifest-file-extension": "error", "manifest-is-valid": "error", diff --git a/.lighthouserc.yml b/.lighthouserc.yml index fc7c111..d06a05d 100644 --- a/.lighthouserc.yml +++ b/.lighthouserc.yml @@ -56,7 +56,7 @@ ci: - offline-start-url - offscreen-images throttling: - cpuSlowdownMultiplier: 3.4 # seems about right on builds.sr.ht + cpuSlowdownMultiplier: 4.2 # seems about right on builds.sr.ht throttlingMethod: devtools url: - https://staging.seirdy.one/ diff --git a/Makefile b/Makefile index b1c4a22..62cc378 100644 --- a/Makefile +++ b/Makefile @@ -63,10 +63,13 @@ test: lint-css hint-devserver check-links .PHONY: build build: hugo # gzip_static + max zopfli compression -ifndef NO_GZIP_STATIC +ifndef NO_STATIC find $(OUTPUT_DIR) -type f -name '*.html' -o -name '*.css' -o -name '*.xml' -o -name '*.txt' -o -name '*.asc' -o -name '*.webmanifest' \ | grep -v gemini \ | xargs zopfli --i$(ZOPFLI_ITERATIONS) --gzip + find $(OUTPUT_DIR) -type f -name '*.html' -o -name '*.css' -o -name '*.xml' -o -name '*.txt' -o -name '*.asc' -o -name '*.webmanifest' \ + | grep -v gemini \ + | xargs brotli -q 11 endif diff --git a/README.md b/README.md index b764851..28da9e8 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,8 @@ To build: - Hugo 0.75 or later - Make - Git (Hugo uses Git info for features like date last updated) -- Zopfli (optional; set `NO_GZIP_STATIC=1` to disable) +- Zopfli (optional; set `NO_STATIC=1` to disable) +- Brotli (optional; set `NO_STATIC=1` to disable) - POSIX utils: grep, find, etc. To deploy: