7 releases

0.2.0 Oct 20, 2025
0.2.0-rc.2 Oct 16, 2025
0.1.2 Jul 27, 2025

#196 in WebAssembly

Download history 14009/week @ 2025-12-16 11821/week @ 2025-12-23 17306/week @ 2025-12-30 15481/week @ 2026-01-06 14401/week @ 2026-01-13 12624/week @ 2026-01-20 14113/week @ 2026-01-27 22547/week @ 2026-02-03 21705/week @ 2026-02-10 25854/week @ 2026-02-17 21086/week @ 2026-02-24 28020/week @ 2026-03-03 31467/week @ 2026-03-10 26778/week @ 2026-03-17 25673/week @ 2026-03-24 22745/week @ 2026-03-31

112,368 downloads per month
Used in 272 crates (via leptos)

MIT/Apache

13KB
200 lines

Annotate functions as appropriate split points for lazy-loaded code in WebAssembly (WASM).

use wasm_split_helpers::wasm_split;

#[wasm_split(rot13_cipher)]
fn rot13(text: &str) -> String {
    text.chars()
        .map(|c| match c {
            'A'..='M' | 'a'..='m' => ((c as u8) + 13) as char,
            'N'..='Z' | 'n'..='z' => ((c as u8) - 13) as char,
            _ => c,
        })
        .collect()
}

async fn check_passphrase(cipher: &str) {
    assert_eq!(rot13(cipher).await, "furrfu", "wrong passphrase!");
}

wasm_split_helpers

This crate provides runtime support for the wasm_split_macros crate, which allows you to indicate that certain functions are appropriate split points for lazy-loaded code in WebAssembly (WASM).

A build tool that supports this approach (like wasm-split-cli in wasm_split_cli_support) can then split a WASM binary into multiple chunks, which will be lazy-loaded on demand.

This crate was adapted from an original prototype, which you can find here, with an in-depth description of the approach here.

This functionality is used:

  • in Leptos to support the #[lazy] and #[lazy_route] macros.
  • in Yew to support the Lazy component

Dependencies

~0.8–1.3MB
~32K SLoC