What is WebAssembly (Wasm)? WebAssembly Explained

Home Glossary What is WebAssembly (Wasm)? WebAssembly Explained

WebAssembly (abbreviated Wasm) is a compact binary format for running code at near-native speed, in the browser and beyond. Instead of writing everything in JavaScript, developers can compile code written in languages such as Rust, C, C++, Go or C# to WebAssembly and run it safely inside a web page. WebAssembly has been an official W3C standard since 2019 and is supported by all major browsers.

How does WebAssembly work?

  • Compilation: source code is compiled to a .wasm module, a compact binary format that loads and starts quickly.
  • Sandbox: the module runs in an isolated environment and can only access what the host (the browser or runtime) explicitly gives it.
  • Together with JavaScript: in the browser, JavaScript loads the module and calls its functions; WebAssembly handles the heavy computation, JavaScript the page and the DOM.
  • Portable: the same module runs on any operating system and processor that has a WebAssembly runtime.

What is WebAssembly used for?

In the browser, WebAssembly powers applications that would be too slow in JavaScript: design tools such as Figma, Photoshop and AutoCAD on the web, video and audio editing, 3D and games, CAD, data analysis, encryption, and running existing C++ or Rust libraries in a web app. Outside the browser, WebAssembly is used for edge computing (for example Cloudflare Workers and Fastly), safe plugin systems in which customers run their own code inside a platform, and smart contracts on some blockchains. The WASI standard gives WebAssembly controlled access to files, network and other system functions outside the browser.

WebAssembly vs. JavaScript

WebAssembly doesn't replace JavaScript; the two complement each other. JavaScript remains the best choice for user interfaces and most web logic. WebAssembly wins for CPU-heavy work, predictable performance, and reusing code written in other languages. Calls between JavaScript and WebAssembly have some overhead, so the best gains come from handing over larger chunks of work at once.

Points of attention

WebAssembly modules can become large if they include a full runtime, as with Go or C#; Rust and C produce small modules. Debugging is harder than plain JavaScript, and direct DOM access still goes through JavaScript. For many web apps, well-optimised JavaScript is fast enough; WebAssembly is worth it where performance or code reuse clearly matters. See our WebAssembly development and Rust development.

Frequently Asked Questions about WebAssembly

Is WebAssembly faster than JavaScript?

For CPU-heavy tasks usually yes, often considerably. For ordinary web logic and DOM work, the difference is small or JavaScript is just as fast.

Which languages compile to WebAssembly?

Rust, C and C++ have the most mature support. Go, C# (via Blazor), Kotlin, Swift, Zig and AssemblyScript can also compile to WebAssembly.

Is WebAssembly secure?

WebAssembly runs in a sandbox with the same security rules as JavaScript in the browser. It can only use the functions the host explicitly makes available.

Can WebAssembly run outside the browser?

Yes. Runtimes such as Wasmtime and Wasmer, edge platforms and plugin systems run WebAssembly on servers and devices, with WASI for system access.