WebAssembly
In one line
WebAssembly (Wasm) is a binary instruction format that runs in the browser at near-native speed, alongside JavaScript.
In simple words
WebAssembly is a low-level binary instruction format designed as a portable compilation target for languages like C, C++, and Rust. The browser decodes and executes Wasm modules much faster than parsing JavaScript, because Wasm is already close to machine code and skips the parse and JIT warm-up steps.
Wasm does not replace JavaScript — it runs alongside it. You typically write performance-critical parts (image processing, physics, encryption, video codecs) in C++/Rust, compile them to Wasm, and call them from JavaScript. The two share memory via linear memory and exchange data through explicit APIs.
Use cases include games, video/audio editing, scientific simulation, and porting desktop applications to the web. Wasm is sandboxed for security and supported in all major browsers. Tooling like Emscripten (C/C++) and wasm-pack (Rust) helps you build and ship Wasm modules.
Example
// Loading a WebAssembly module (compiled from C/Rust)
async function runWasm() {
const response = await fetch("math.wasm");
const bytes = await response.arrayBuffer();
const { instance } = await WebAssembly.instantiate(bytes);
// Call a function exported from the Wasm module
console.log(instance.exports.add(2, 3)); // 5
}
runWasm();The browser fetches the .wasm binary, instantiates it, and calls exported functions. The add() function runs at near-native speed.
Related terms
Related Resources
Related Lessons
- WebAssembly
Learn WebAssembly basics.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.