WASM–JavaScript Interop Vocabulary
Learn WebAssembly–JavaScript interop vocabulary: wasm-bindgen, WebAssembly.instantiate, passing data between WASM and JS, and working with WASM module exports.
Vocabulary Reference
- WebAssembly.instantiate()
- The primary browser API to compile and instantiate a .wasm binary. Accepts a BufferSource or WebAssembly.Module and an optional import object; resolves with the compiled module and instance.
- wasm-bindgen
- A Rust tool that auto-generates JavaScript glue code so Rust-compiled WASM can pass rich types (strings, structs, closures) to and from JavaScript without manual memory management.
- import object
- A plain JavaScript object passed to WebAssembly.instantiate() that supplies host functions and memory to the WASM module's declared imports.
- the WASM module exposes
- A common phrase indicating that a function or value is listed in the module's export section and is callable from JavaScript after instantiation.
- passing data between WASM and JS
- Because WASM functions only accept numbers, passing strings or arrays requires writing data into linear memory and passing pointers — or using wasm-bindgen/Emscripten glue to automate this.
- memory.grow()
- A WASM instruction (and JavaScript WebAssembly.Memory method) that increases linear memory by a given number of 64 KiB pages.