From ecd72cc3bccf4c1503af36f1eae2042e9ffdae19 Mon Sep 17 00:00:00 2001 From: "Jiaxiao (mossaka) Zhou" Date: Thu, 19 Feb 2026 04:58:18 +0000 Subject: [PATCH] Add brotli pre-compression for gh-aw.wasm binary The bundle script now generates a brotli-compressed (.br) version of the WASM binary after copying it to the docs site, reducing transfer size from ~17 MB to ~5 MB. Falls back to gzip if brotli CLI is not installed. Updates the loading message to reflect the compressed size and adds .br/.gz artifacts to .gitignore. Co-Authored-By: Claude Opus 4.6 --- .gitignore | 2 ++ docs/public/editor/index.html | 2 +- scripts/bundle-wasm-docs.sh | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f636cdc0ca6..97aa9b7108f 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,8 @@ Thumbs.db *.wasm /wasm_exec.js docs/public/wasm/gh-aw.wasm +docs/public/wasm/gh-aw.wasm.br +docs/public/wasm/gh-aw.wasm.gz docs/public/wasm/wasm_exec.js # Go binary for this project diff --git a/docs/public/editor/index.html b/docs/public/editor/index.html index b9c208404e9..1141950d39d 100644 --- a/docs/public/editor/index.html +++ b/docs/public/editor/index.html @@ -130,7 +130,7 @@
Loading gh-aw compiler...
-
Downloading WebAssembly module (~17 MB)
+
Downloading WebAssembly module (~5 MB compressed)
diff --git a/scripts/bundle-wasm-docs.sh b/scripts/bundle-wasm-docs.sh index ddb74f7959f..466b22b0117 100755 --- a/scripts/bundle-wasm-docs.sh +++ b/scripts/bundle-wasm-docs.sh @@ -35,6 +35,19 @@ if [ ! -f "${WASM_EXEC_SRC}" ]; then fi cp "${WASM_EXEC_SRC}" "${DEST_DIR}/wasm_exec.js" +# Generate brotli-compressed version for smaller transfers +# GitHub Pages serves .br files automatically when Accept-Encoding: br is present +if command -v brotli &> /dev/null; then + echo "==> Compressing WASM with brotli..." + brotli -k -q 11 "${DEST_DIR}/gh-aw.wasm" + echo "Compressed: $(du -h "${DEST_DIR}/gh-aw.wasm.br" | cut -f1) (from $(du -h "${DEST_DIR}/gh-aw.wasm" | cut -f1))" +else + echo "Warning: brotli not found. Install with: apt-get install brotli (or brew install brotli)" + echo "Falling back to gzip compression..." + gzip -k -9 "${DEST_DIR}/gh-aw.wasm" + echo "Compressed: $(du -h "${DEST_DIR}/gh-aw.wasm.gz" | cut -f1) (from $(du -h "${DEST_DIR}/gh-aw.wasm" | cut -f1))" +fi + echo "" echo "Done. Files in ${DEST_DIR}:" ls -lh "${DEST_DIR}/gh-aw.wasm" "${DEST_DIR}/wasm_exec.js"