WebAssembly

WebAssembly is a 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 app, 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 module, 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 text format into a Wasm binary.

API reference

WebAssembly instruction reference

Reference documentation with interactive samples for the set of WebAssembly operators.

WebAssembly JavaScript interface

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 more WebAssembly.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 a Module. Instance objects contain all the Exported WebAssembly functions that allow calling into WebAssembly code from JavaScript.

WebAssembly.compile()

The WebAssembly.compile() function compiles WebAssembly binary code into a WebAssembly.Module object.

WebAssembly.compileStreaming()

The WebAssembly.compileStreaming() function compiles a WebAssembly.Module directly from a streamed underlying source.

WebAssembly.instantiate()

The WebAssembly.instantiate() function allows you to compile and instantiate WebAssembly code.

WebAssembly.instantiateStreaming()

The WebAssembly.instantiateStreaming() function is the primary API for compiling and instantiating WebAssembly code, returning both a Module and its first Instance.

WebAssembly.validate()

The WebAssembly.validate() function validates a given typed array of WebAssembly binary code.

WebAssembly.Memory()

A WebAssembly.Memory object is a resizable ArrayBuffer that holds the raw bytes of memory accessed by an Instance.

WebAssembly.Table()

A WebAssembly.Table object is a resizable typed array of opaque values, like function references, that are accessed by an Instance.

WebAssembly.Tag()

The WebAssembly.Tag object defines a type of WebAssembly exception that can be thrown to/from WebAssembly code.

WebAssembly.Exception()

The WebAssembly.Exception object represents a runtime exception thrown from WebAssembly to JavaScript, or thrown from JavaScript to a WebAssembly exception handler.

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

Specifications

Specification
WebAssembly JavaScript Interface
# webassembly-namespace
WebAssembly JavaScript Interface
# ref-for-syntax-numtype①⓪
Unknown specification
Unknown specification
Unknown specification
Unknown specification
WebAssembly Core: Garbage Collection
# garbage-collection①
Unknown specification
Unknown specification
WebAssembly JavaScript Interface
# dom-globaldescriptor-mutable
Unknown specification
Unknown specification
Unknown specification
Unknown specification
Unknown specification

Browser compatibility

webassembly.api

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
api
CompileError
CompileError() constructor
Exception
Exception() constructor
options.traceStack parameter
Non-standard
Exception.getArg
Exception.is
Stack trace
Non-standard
Global
Global() constructor
Global.value
Global.valueOf
Instance
Instance() constructor
Instance.exports
LinkError
LinkError() constructor
Memory
Memory() constructor
shared flag
Memory.buffer
Memory.grow
Module
Module() constructor
compileOptions parameter
customSections() static method
exports() static method
imports() static method
RuntimeError
RuntimeError() constructor
Table
Table() constructor
Table.get
Table.grow
Table.length
Table.set
Tag
Tag() constructor
Tag.type
compileStreaming() static method
compileOptions parameter
compile() static method
compileOptions parameter
instantiateStreaming() static method
compileOptions parameter
instantiate() static method
compileOptions parameter
validate() static method
compileOptions parameter

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Non-standard. Check cross-browser support before using.
See implementation notes.
User must explicitly enable this feature.

webassembly.BigInt-to-i64-integration

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
BigInt-to-i64-integration

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

webassembly.bulk-memory-operations

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
bulk-memory-operations

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

webassembly.exception-handling

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Legacy exception handling

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

webassembly.extended-constant-expressions

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
extended-constant-expressions

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

webassembly.fixed-width-SIMD

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
fixed-width-SIMD

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

webassembly.garbage-collection

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
garbage-collection

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

webassembly.multiMemory

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
multiMemory

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

webassembly.multi-value

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
multi-value

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

webassembly.mutable-globals

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
mutable-globals

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

webassembly.non-trapping-float-to-int-conversions

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
non-trapping-float-to-int-conversions

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

webassembly.reference-types

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
reference-types

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

webassembly.sign-extension-operations

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
sign-extension-operations

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

webassembly.tail-calls

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
tail-calls

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

webassembly.threads-and-atomics

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
threads-and-atomics

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

See also