Summary
Near-native compute in browser — port codecs, editors, games from C/Rust. JS↔WASM boundary has marshaling cost; bulk work inside WASM. Threading needs SAB + COOP/COEP. Load size vs JS — measure before adopting for small helpers.
Code example
const wasm = await WebAssembly.instantiateStreaming(
fetch('/pkg/compress.wasm'),
imports,
);
const result = wasm.instance.exports.compress(inputPtr, inputLen);
Key points
- Near-native compute in browser — port codecs, editors, games from C/Rust.
- JS↔WASM boundary has marshaling cost; bulk work inside WASM.
- Threading needs SAB + COOP/COEP.
- Load size vs JS — measure before adopting for small helpers.