Back to Wasm Bindgen

WebAssembly JSPI Example

examples/jspi/index.html

0.2.128588 B
Original Source

WebAssembly JSPI Example

JSPI lets plain (non-async) Rust functions await JS Promises by suspending the WASM fiber — without blocking the browser's event loop. Open DevTools to follow the timings.

With the fully integrated JSPI support in wasm-bindgen, no manual bridge setup is required:

  • Imports marked #[wasm_bindgen(suspending)] are automatically wrapped with new WebAssembly.Suspending(...) by the generated glue.
  • Exports marked #[wasm_bindgen(jspi)] are automatically wrapped with WebAssembly.promising via a lazy cache in the generated glue.
Loading…