The WebAssembly JavaScript object acts as the namespace for all WebAssembly-related functionality.

Documentation WebAssembly by Mozilla Contributors, licensed under CC-BY-SA 2.5.

Static methods

staticcompile(bufferSource:ArrayBuffer):Promise<Module>

staticcompile(bufferSource:Int8Array):Promise<Module>

staticcompile(bufferSource:Uint8Array):Promise<Module>

staticcompile(bufferSource:Uint8ClampedArray):Promise<Module>

staticcompile(bufferSource:Int16Array):Promise<Module>

staticcompile(bufferSource:Uint16Array):Promise<Module>

staticcompile(bufferSource:Int32Array):Promise<Module>

staticcompile(bufferSource:Uint32Array):Promise<Module>

staticcompile(bufferSource:Float32Array):Promise<Module>

staticcompile(bufferSource:Float64Array):Promise<Module>

The WebAssembly.compile() function compiles a WebAssembly Module from WebAssembly binary code. This function is useful if it is necessary to a compile a module before it can be instantiated (otherwise, the WebAssembly.instantiate() function should be used).

staticcompileStreaming(source:Response):Promise<Module>

The WebAssembly.compileStreaming() function compiles a WebAssembly Module directly from a streamed underlying source. This function is useful if it is necessary to a compile a module before it can be instantiated (otherwise, the WebAssembly.instantiateStreaming() function should be used).

staticinstantiate(bufferSource:ArrayBuffer, importObject:{}):Promise<WebAssemblyInstantiatedSource>

staticinstantiate(bufferSource:Int8Array, importObject:{}):Promise<WebAssemblyInstantiatedSource>

staticinstantiate(bufferSource:Uint8Array, importObject:{}):Promise<WebAssemblyInstantiatedSource>

staticinstantiate(bufferSource:Uint8ClampedArray, importObject:{}):Promise<WebAssemblyInstantiatedSource>

staticinstantiate(bufferSource:Int16Array, importObject:{}):Promise<WebAssemblyInstantiatedSource>

staticinstantiate(bufferSource:Uint16Array, importObject:{}):Promise<WebAssemblyInstantiatedSource>

staticinstantiate(bufferSource:Int32Array, importObject:{}):Promise<WebAssemblyInstantiatedSource>

staticinstantiate(bufferSource:Uint32Array, importObject:{}):Promise<WebAssemblyInstantiatedSource>

staticinstantiate(bufferSource:Float32Array, importObject:{}):Promise<WebAssemblyInstantiatedSource>

staticinstantiate(bufferSource:Float64Array, importObject:{}):Promise<WebAssemblyInstantiatedSource>

staticinstantiate(module:Module, importObject:{}):Promise<Instance>

The WebAssembly.instantiate() function allows you to compile and instantiate WebAssembly code. This function has two overloads:

  • The primary overload takes the WebAssembly binary code, in the form of a typed array or ArrayBuffer, and performs both compilation and instantiation in one step. The returned Promise resolves to both a compiled WebAssembly.Module and its first WebAssembly.Instance.

    - The secondary overload takes an already-compiled WebAssembly.Module and returns a Promise that resolves
    

    to an Instance of that Module. This overload is useful if the Module has already been compiled.

staticinstantiateStreaming(source:Response, importObject:{}):Promise<WebAssemblyInstantiatedSource>

The WebAssembly.instantiateStreaming() function compiles and instantiates a WebAssembly module directly from a streamed underlying source. This is the most efficient, optimized way to load wasm code.

staticvalidate(bufferSource:ArrayBuffer):Bool

staticvalidate(bufferSource:Int8Array):Bool

staticvalidate(bufferSource:Uint8Array):Bool

staticvalidate(bufferSource:Uint8ClampedArray):Bool

staticvalidate(bufferSource:Int16Array):Bool

staticvalidate(bufferSource:Uint16Array):Bool

staticvalidate(bufferSource:Int32Array):Bool

staticvalidate(bufferSource:Uint32Array):Bool

staticvalidate(bufferSource:Float32Array):Bool

staticvalidate(bufferSource:Float64Array):Bool

The WebAssembly.validate() function validates a given typed array of WebAssembly binary code, returning whether the bytes form a valid wasm module (true) or not (false).