-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Summary
The River UI container contract state is 2.2MB, which contributes to slow initial load times. While not the primary cause of slow loads (network join time is the bigger factor), reducing this size would improve user experience.
Current State
The contract state contains the bundled UI assets:
| Component | Size | Notes |
|---|---|---|
river-ui_bg.wasm |
2.3MB | Dioxus UI compiled to WASM |
bulma.min.css |
672K | Full CSS framework |
| FontAwesome fonts | ~400K | Full icon set |
| Total uncompressed | ~5.5MB | |
| Compressed (xz) | ~2.2MB | What's actually transferred |
The Cargo profile is already well-optimized:
opt-level = 'z'
lto = true
strip = trueOptimization Opportunities
1. Install and use wasm-opt
Could reduce WASM size by 20-30%. Add to build process:
wasm-opt -Oz -o output.wasm input.wasm2. PurgeCSS for Bulma
Remove unused CSS classes from bulma.min.css - likely only using a fraction of the framework.
3. FontAwesome subsetting
Include only the icons actually used in the UI rather than the full icon set.
4. Verify Brotli serving
The build creates .br files (river-ui_bg.wasm.br is 583K vs 2.3MB uncompressed). Verify Freenet serves these when the browser supports Brotli.
Context
Discovered while investigating slow River UI load times. The 2.2MB transfer over a small test network (2-3 peers) through 10 hops took ~33 seconds. Reducing contract size would help, though improving network topology/routing would have a bigger impact.
[AI-assisted - Claude]