-
Notifications
You must be signed in to change notification settings - Fork 295
Add brotli pre-compression for WASM binary #16752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+38
to
+39
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Generate brotli-compressed version for smaller transfers | |
| # GitHub Pages serves .br files automatically when Accept-Encoding: br is present | |
| # Generate brotli-compressed version for smaller transfers. | |
| # Note: GitHub Pages does not automatically serve .br files; these are for use with a CDN or custom setup. |
Copilot
AI
Feb 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The final ls command only lists the uncompressed WASM file and wasm_exec.js, but doesn't show the newly created compressed files (.br or .gz). This makes it difficult to verify that the compression step succeeded.
Consider updating the ls command to include the compressed files. For example:
- If brotli succeeds, list gh-aw.wasm.br
- If gzip fallback is used, list gh-aw.wasm.gz
This would provide better visibility into what files were actually created by the script.
| 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" | |
| COMPRESSED_EXT="" | |
| 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))" | |
| COMPRESSED_EXT="br" | |
| 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))" | |
| COMPRESSED_EXT="gz" | |
| fi | |
| echo "" | |
| echo "Done. Files in ${DEST_DIR}:" | |
| if [ -n "${COMPRESSED_EXT}" ]; then | |
| ls -lh "${DEST_DIR}/gh-aw.wasm" "${DEST_DIR}/gh-aw.wasm.${COMPRESSED_EXT}" "${DEST_DIR}/wasm_exec.js" | |
| else | |
| ls -lh "${DEST_DIR}/gh-aw.wasm" "${DEST_DIR}/wasm_exec.js" | |
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loading message was updated to show "~5 MB compressed" but the updated message may be misleading since GitHub Pages does not automatically serve the compressed .br files. Users will still download the full uncompressed ~17 MB .wasm file unless additional configuration or code changes are made to explicitly fetch and decompress the .br file.
This change should be coordinated with actual implementation to serve the compressed file, otherwise users will see a message claiming ~5 MB but actually download ~17 MB, leading to a confusing user experience.