WebAssembly is a new type of code that can be run in modern web browsers — it is a low-level assembly-like language with a compact binary format that runs with near-native performance and provides languages such as C/C++, C# and Rust with a compilation target so that they can run on the web. It is also designed to run alongside JavaScript, allowing both to work together.
In a Nutshell
WebAssembly has huge implications for the web platform — it provides a way to run code written in multiple languages on the web at near native speed, with client apps running on the web that previously couldn’t have done so.
WebAssembly is designed to complement and run alongside JavaScript — using the WebAssembly JavaScript APIs, you can load WebAssembly modules into a JavaScript app and share functionality between the two. This allows you to take advantage of WebAssembly's performance and power and JavaScript's expressiveness and flexibility in the same apps, even if you don't know how to write WebAssembly code.
And what's even better is that it is being developed as a web standard via the W3C WebAssembly Working Group and Community Group with active participation from all major browser vendors.
Guides
- WebAssembly concepts
- Get started by reading the high-level concepts behind WebAssembly — what it is, why it is so useful, how it fits into the web platform (and beyond), and how to use it.
- Compiling a New C/C++ Module to WebAssembly
- When you’ve written code in C/C++, you can then compile it into .wasm using a tool like Emscripten. Let’s look at how it works.
- Compiling an Existing C Module to WebAssembly
- A core use-case for WebAssembly is to take the existing ecosystem of C libraries and allow developers to use them on the web.
- Compiling from Rust to WebAssembly
- If you've written some Rust code, you can compile it into WebAssembly! This tutorial takes you through all you need to know to compile a Rust project to wasm and use it in an existing web app.
- Loading and running WebAssembly code
- After you have a .wasm, this article covers how to fetch, compile and instantiate it, combining the WebAssembly JavaScript API with the Fetch or XHR APIs.
- Using the WebAssembly JavaScript API
- Once you've loaded a .wasm module, you'll want to use it. In this article we show you how to use WebAssembly via the WebAssembly JavaScript API.
- Exported WebAssembly functions
- Exported WebAssembly functions are the JavaScript reflections of WebAssembly functions which allow calling WebAssembly code from JavaScript. This article describes what they are.
- Understanding WebAssembly text format
- This article explains the wasm text format. This is the low-level textual representation of a .wasm module shown in browser developer tools when debugging.
- Converting WebAssembly text format to wasm
- This article provides a guide on how to convert a WebAssembly module written in the text format into a .wasm binary.
API reference
WebAssembly
- This object acts as the namespace for all WebAssembly related functionality.
WebAssembly.Global()
- A
WebAssembly.Global
object represents a global variable instance, accessible from both JavaScript and importable/exportable across one or moreWebAssembly.Module
instances. This allows dynamic linking of multiple modules. WebAssembly.Module()
- A
WebAssembly.Module
object contains stateless WebAssembly code that has already been compiled by the browser and can be efficiently shared with Workers, and instantiated multiple times. WebAssembly.Instance()
- A
WebAssembly.Instance
object is a stateful, executable instance of aModule
.Instance
objects contain all the Exported WebAssembly functions that allow calling into WebAssembly code from JavaScript. WebAssembly.instantiateStreaming()
- The
WebAssembly.instantiateStreaming()
function is the primary API for compiling and instantiating WebAssembly code, returning both aModule
and its firstInstance
. WebAssembly.Memory()
- A
WebAssembly.Memory
object is a resizableArrayBuffer
that holds the raw bytes of memory accessed by anInstance
. WebAssembly.Table()
- A
WebAssembly.Table
object is a resizable typed array of opaque values, like function references, that are accessed by anInstance
. WebAssembly.CompileError()
- Creates a new WebAssembly
CompileError
object. WebAssembly.LinkError()
- Creates a new WebAssembly
LinkError
object. WebAssembly.RuntimeError()
- Creates a new WebAssembly
RuntimeError
object.
Examples
- WASMSobel
- See our webassembly-examples repo for a number of other examples.
Specifications
Specification | Status | Comment |
---|---|---|
WebAssembly JavaScript Interface | Working Draft | Initial draft definition of the JavaScript API. |
Browser compatibility
Desktop | Mobile | Server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
WebAssembly | Chrome Full support 57 | Edge Full support 16 | Firefox
Full support
52
| IE No support No | Opera Full support 44 | Safari Full support 11 | WebView Android Full support 57 | Chrome Android Full support 57 | Firefox Android
Full support
52
| Opera Android Full support 43 | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |
CompileError | Chrome Full support 57 | Edge Full support 16 | Firefox
Full support
52
| IE No support No | Opera Full support 44 | Safari Full support 11 | WebView Android Full support 57 | Chrome Android Full support 57 | Firefox Android
Full support
52
| Opera Android Full support 43 | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |
Global | Chrome Full support 69 | Edge No support No | Firefox Full support 62 | IE No support No | Opera No support No | Safari Full support 13.1 | WebView Android Full support 69 | Chrome Android Full support 69 | Firefox Android Full support 62 | Opera Android No support No | Safari iOS Full support 13.4 | Samsung Internet Android Full support 10.0 | nodejs No support No |
Instance | Chrome Full support 57 | Edge Full support 16 | Firefox
Full support
52
| IE No support No | Opera Full support 44 | Safari Full support 11 | WebView Android Full support 57 | Chrome Android Full support 57 | Firefox Android
Full support
52
| Opera Android Full support 43 | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |
LinkError | Chrome Full support 57 | Edge Full support 16 | Firefox
Full support
52
| IE No support No | Opera Full support 44 | Safari Full support 11 | WebView Android Full support 57 | Chrome Android Full support 57 | Firefox Android
Full support
52
| Opera Android Full support 43 | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |
Memory | Chrome Full support 57 | Edge Full support 16 | Firefox
Full support
52
| IE No support No | Opera Full support 44 | Safari Full support 11 | WebView Android Full support 57 | Chrome Android Full support 57 | Firefox Android
Full support
52
| Opera Android Full support 43 | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |
Module | Chrome Full support 57 | Edge Full support 16 | Firefox
Full support
52
| IE No support No | Opera Full support 44 | Safari Full support 11 | WebView Android Full support 57 | Chrome Android Full support 57 | Firefox Android
Full support
52
| Opera Android Full support 43 | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |
RuntimeError | Chrome Full support 57 | Edge Full support 16 | Firefox
Full support
52
| IE No support No | Opera Full support 44 | Safari Full support 11 | WebView Android Full support 57 | Chrome Android Full support 57 | Firefox Android
Full support
52
| Opera Android Full support 43 | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |
Table | Chrome Full support 57 | Edge Full support 16 | Firefox
Full support
52
| IE No support No | Opera Full support 44 | Safari Full support 11 | WebView Android Full support 57 | Chrome Android Full support 57 | Firefox Android
Full support
52
| Opera Android Full support 43 | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |
compile | Chrome Full support 57 | Edge Full support 16 | Firefox
Full support
52
| IE No support No | Opera Full support 44 | Safari Full support 11 | WebView Android Full support 57 | Chrome Android Full support 57 | Firefox Android
Full support
52
| Opera Android Full support 43 | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |
compileStreaming | Chrome Full support 61 | Edge Full support 16 | Firefox Full support 58 | IE No support No | Opera Full support 47 | Safari No support No | WebView Android Full support 61 | Chrome Android Full support 61 | Firefox Android Full support 58 | Opera Android Full support 45 | Safari iOS No support No | Samsung Internet Android Full support 8.0 | nodejs No support No |
instantiate | Chrome Full support 57 | Edge Full support 16 | Firefox
Full support
52
| IE No support No | Opera Full support 44 | Safari Full support 11 | WebView Android Full support 57 | Chrome Android Full support 57 | Firefox Android
Full support
52
| Opera Android Full support 43 | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |
instantiateStreaming | Chrome Full support 61 | Edge Full support 16 | Firefox Full support 58 | IE No support No | Opera Full support 47 | Safari No support No | WebView Android Full support 61 | Chrome Android Full support 61 | Firefox Android Full support 58 | Opera Android Full support 45 | Safari iOS No support No | Samsung Internet Android Full support 8.0 | nodejs No support No |
validate | Chrome Full support 57 | Edge Full support 16 | Firefox
Full support
52
| IE No support No | Opera Full support 44 | Safari Full support 11 | WebView Android Full support 57 | Chrome Android Full support 57 | Firefox Android
Full support
52
| Opera Android Full support 43 | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.
- See implementation notes.