diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index ff0bf0e..45b5e31 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -163,3 +163,42 @@ jobs:
- name: Build with Trunk
run: trunk build --release
+
+ - name: Asset size budget
+ # Fails the build if any critical asset exceeds its gzipped budget.
+ # Budgets carry roughly +25% headroom over the current sizes so
+ # routine changes don't trip them, but a careless dependency
+ # bump or stylesheet bloat will. Update the budget alongside the
+ # change that exceeds it, with a clear justification in the PR.
+ run: |
+ set -euo pipefail
+ fail=0
+ check() {
+ local pattern="$1"
+ local label="$2"
+ local budget_kb="$3"
+ local file
+ file=$(ls dist/$pattern 2>/dev/null | head -n1 || true)
+ if [ -z "$file" ]; then
+ echo "::error::Budget check: no file matching dist/$pattern"
+ fail=1
+ return
+ fi
+ local size_b
+ size_b=$(gzip -c -9 "$file" | wc -c)
+ local size_kb=$(( (size_b + 1023) / 1024 ))
+ if [ "$size_kb" -gt "$budget_kb" ]; then
+ echo "::error::$label is ${size_kb} KB gz, budget is ${budget_kb} KB ($file)"
+ fail=1
+ else
+ echo "OK: $label = ${size_kb} KB gz (budget ${budget_kb} KB) -- $file"
+ fi
+ }
+ check 'odp-*_bg.wasm' 'wasm' 230
+ check 'tailwind-*.css' 'tailwind CSS' 10
+ check 'repo_graph.css' 'repo_graph CSS' 2
+ check 'odp-*.js' 'wasm-bindgen JS' 20
+ if [ "$fail" -ne 0 ]; then
+ echo "::error::One or more assets exceeded their size budget."
+ exit 1
+ fi
diff --git a/Cargo.toml b/Cargo.toml
index 842e6b3..1898377 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,7 +9,12 @@ leptos = { version = "0.8.2", features = ["csr"] }
leptos_meta = "0.8.2"
leptos_router = "0.8.2"
wasm-bindgen = "0.2.100"
-web-sys = { version = "0.3.77", features = ["Document", "Window", "console"] }
+# All the web-sys features we use directly (Window, Document, Console)
+# are already enabled transitively by leptos's `csr` feature, so we
+# don't need to opt into them again here. We still depend on web-sys
+# directly for the `web_sys::js_sys` re-export and `web_sys::window()`
+# in `repo_view.rs`.
+web-sys = "0.3.77"
[dev-dependencies]
js-sys = "0.3"
@@ -21,4 +26,8 @@ wasm-bindgen-test = "0.3"
assets-dir="public"
[profile.release]
+opt-level = "z"
+lto = "fat"
+codegen-units = 1
+panic = "abort"
strip = true
diff --git a/Trunk.toml b/Trunk.toml
index b6f3a0f..0b9b60f 100644
--- a/Trunk.toml
+++ b/Trunk.toml
@@ -19,8 +19,10 @@ inject_scripts = true
# frozen = false
# Require Cargo.lock is up to date
# locked = false
-# Control minification
-# minify = "never" # can be one of: never, on_release, always
+# Control minification: "always" minifies CSS (incl. tailwind) and HTML
+# in both dev and release builds. The wasm artifact is governed by the
+# cargo release profile (Cargo.toml) -- this only affects asset minify.
+minify = "always"
# Allow disabling sub-resource integrity (SRI)
# no_sri = false
# An optional cargo profile to use
diff --git a/index.html b/index.html
index 6fd059e..d4fd670 100644
--- a/index.html
+++ b/index.html
@@ -5,15 +5,18 @@
-
+
+
+
-
-
-
+