Skip to content

Optimize UI container contract size (currently 2.2MB) #57

@sanity

Description

@sanity

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 = true

Optimization 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.wasm

2. 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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions