From 6329d000f5d7e9bfba6ab1aab51c9a6e9d9dd5be Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Sat, 15 Nov 2025 14:42:03 -0600 Subject: [PATCH] Use compressed WASM for even smaller webroot size --- Makefile | 13 +++++++------ www/index.html | 6 +++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index e99f015a..742d0290 100644 --- a/Makefile +++ b/Makefile @@ -17,19 +17,19 @@ SRCS := $(wildcard $(SRC_DIR)/**) # "Standalone" version # (i.e., it includes an index.html so it can be placed on a server as-is) -web-standalone: out/boids.js out/boids_bg.wasm out/index.html +web-standalone: out/boids.js out/boids_bg.wasm.gz out/index.html # "Bundle-able" version. The host site must provide it's own HTML page. -web: out/boids.js out/boids_bg.wasm out/boids.html +web: out/boids.js out/boids_bg.wasm.gz out/boids.html tarball: boids_web_root.tar tarball_standalone: boids_web_root_standalone.tar -boids_web_root.tar: out/boids.js out/boids_bg.wasm out/boids.html +boids_web_root.tar: out/boids.js out/boids_bg.wasm.gz out/boids.html tar -caf $@ $^ -boids_web_root_standalone.tar: out/boids.js out/boids_bg.wasm out/index.html +boids_web_root_standalone.tar: out/boids.js out/boids_bg.wasm.gz out/index.html tar -caf $@ $^ target/$(CARGO_TARGET)/$(CARGO_PROFILE)/another-boids-in-rust.wasm: $(SRCS) Cargo.lock Cargo.toml @@ -40,8 +40,9 @@ out: # Both the JS and WASM files are generated by the wasm-bindgen call, so both # get to be on the target half of this recipe. -out/boids.js out/boids_bg.wasm &: target/$(CARGO_TARGET)/$(CARGO_PROFILE)/another-boids-in-rust.wasm | out +out/boids.js out/boids_bg.wasm.gz &: target/$(CARGO_TARGET)/$(CARGO_PROFILE)/another-boids-in-rust.wasm | out wasm-bindgen --no-typescript --target web --out-dir ./out/ --out-name boids target/$(CARGO_TARGET)/$(CARGO_PROFILE)/another-boids-in-rust.wasm + gzip -9 -f out/boids_bg.wasm # Copies the index page to the output out/index.html: www/index.html @@ -68,5 +69,5 @@ full-clean: clean install: web install -dm0755 $(DESTDIR) install -m0644 out/boids.js $(DESTDIR)/ - install -m0644 out/boids_bg.wasm $(DESTDIR)/ + install -m0644 out/boids_bg.wasm.gz $(DESTDIR)/ install -m0644 out/boids.html $(DESTDIR)/ diff --git a/www/index.html b/www/index.html index c18f2409..2d66dcd6 100644 --- a/www/index.html +++ b/www/index.html @@ -112,7 +112,11 @@