What Is WebAssembly?

Updated June 2026
WebAssembly, written wasm for short, is a binary instruction format that runs in every modern browser at close to native speed. You do not write it by hand. You write code in a language like C, C++, or Rust, and a compiler turns it into a compact .wasm file that the browser validates and compiles to real machine code. For games, it is the technology that lets heavy native code and full engines run inside a web page with no plugin and no install.

A Compilation Target, Not a Language

The single most useful thing to understand about WebAssembly is that it is a compilation target rather than a language you type. When you learn JavaScript, you write JavaScript source and the browser runs it. WebAssembly is different. You write your program in some other language, a compiler translates it into the WebAssembly binary format, and the browser runs that binary. The format is designed to be a good target for compilers: compact to download, fast to validate, and quick to turn into the native instructions of whatever CPU the visitor is using.

This is why you rarely see anyone writing WebAssembly directly. There is a human-readable text version called WAT, the WebAssembly Text format, which spells out the instructions in a Lisp-like syntax, and it is genuinely useful for learning and for debugging what a compiler produced. But it exists mainly as a window into the binary, not as a language people build games in. The real authoring languages are C and C++ through the Emscripten toolchain, and Rust through its built-in wasm target. You stay in a comfortable high-level language and let the toolchain handle the translation into wasm.

Because it is a target rather than a language, WebAssembly is also language-neutral by design. The same binary format can be produced from many source languages, which is exactly what makes it valuable for bringing existing native code to the web. A physics engine written in C++ twenty years ago can be compiled to wasm today and run in a browser, because the format was built to receive the output of a C++ compiler, not to be tied to any one language.

How the Browser Runs It So Fast

WebAssembly's speed comes from how the browser treats it. When a wasm module arrives, the browser first validates it, a quick structural check that the bytes describe a safe, well-formed module. Then it compiles the module to native machine code, either fully before execution or in a streaming fashion as the bytes download. By the time your code calls a wasm function, that function is already real machine code running directly on the CPU, with no interpretation step and no warm-up period where it runs slowly until an optimizer notices it.

Contrast this with how JavaScript runs. A JavaScript engine starts by interpreting or quickly compiling your code, watches which functions run hot, and then recompiles those with heavy optimizations, sometimes deoptimizing again if its assumptions break. This just-in-time approach is brilliant and fast, but it means hot code has a warm-up phase and the engine carries the weight of supporting a dynamic language where any value can change type at any moment. WebAssembly skips all of that. Its types are fixed when the compiler produces the binary, so the operations map cleanly onto machine instructions with no runtime type guessing.

The result is performance that is consistent and close to native from the first call. For the steady, every-frame numerical work a game does, integrating physics, transforming vertices, stepping a simulation, that consistency is the whole point. There is no moment where the code is slow because it has not warmed up, and no risk that a change in data shape causes the engine to throw away its optimized version and start over.

Key Takeaway

WebAssembly is compiled to native machine code before it runs, with fixed types and no warm-up, which is why a wasm function performs at full speed from its very first call.

The Sandbox and Linear Memory

A WebAssembly module runs in a strict sandbox. It cannot reach out and touch the page, the canvas, the network, or the filesystem on its own. What it has instead is a block of memory called linear memory, which is simply a large, flat array of bytes that the module reads and writes directly, plus a set of functions it exports for the outside world to call and a set of functions it imports that the outside world provides. Everything the module does to affect anything beyond its own computation flows through that small, explicit interface.

This linear memory model is central to how wasm games work. The module's entire working state, its entities, its physics bodies, its buffers, lives in that flat array of bytes. JavaScript can see the same array as an ArrayBuffer and read or write it through typed-array views. So when a wasm physics module finishes a step, it has written every body's new position into linear memory, and the JavaScript renderer reads those positions straight out of the shared bytes with no copying. That shared, zero-copy access to a flat memory block is exactly what makes the wasm-to-JavaScript handoff fast enough to be worth doing.

The sandbox is also a security feature. Because a module can only touch its own linear memory and can only reach the outside world through the specific functions it was given, a malicious or buggy wasm module cannot read arbitrary browser memory or do anything its imports do not explicitly allow. This is the same safety guarantee that lets the browser run untrusted JavaScript, extended to untrusted compiled code, and it is part of why browsers were willing to ship near-native-speed execution at all.

WebAssembly and JavaScript Are Partners

It is tempting to frame WebAssembly as a rival to JavaScript, but in a real game they are teammates with different jobs. JavaScript is the part of the program that talks to the browser. It creates the canvas, sets up the WebGL or WebGPU context, listens for keyboard and touch input, plays audio, opens network connections, and saves to storage. WebAssembly is the part that computes. It holds the heavy simulation and runs it fast. A typical wasm game is a thin JavaScript shell wrapped around a compute-heavy wasm core, with each doing what it is best at.

The art is in the interface between them. Crossing from JavaScript into wasm and back is fast but not free, so a well-built game keeps the boundary coarse, passing large batches of work across at once and sharing data through linear memory rather than making thousands of tiny calls per frame. This is the same lesson the comparison of wasm and JavaScript returns to again and again: the two are designed to work together, and the games that get the most out of wasm are the ones that respect the boundary between the fast core and the flexible shell.

A Real Web Standard, Available Everywhere

WebAssembly is not experimental and not vendor-specific. It has been supported in Chrome, Firefox, Safari, and Edge for years, and it works on mobile browsers exactly as it does on desktop. When you ship a wasm game, essentially every visitor with a current browser can run it with no flag to enable, no plugin to install, and no permission to grant. This universal availability is what made it credible as the web export target for the major engines, replacing the older asm.js technique and the long-dead native plugins that came before.

For someone building browser games, the bottom line is simple. WebAssembly is the standard, reliable way to run fast, compiled code on the web, and it sits underneath both hand-written native ports and full engine exports. You do not always need it, many great web games are pure JavaScript, but when a game has a genuinely heavy core or a large existing native codebase, wasm is the proven path to bring it to the browser without giving up the open-web distribution that makes web games worth building in the first place.