WebAssembly.Module
object contains stateless WebAssembly code that has already been compiled by the browser and can be efficiently shared with Workers, cached in IndexedDB and instantiated multiple times. The WebAssembly.Module()
constructor function can be called to synchronously compile given WebAssembly binary code. However, the primary way to get a Module
is through an asynchronous compilation function like WebAssembly.compile()
or by reading a Module out of IndexedDB. Important: Since compilation for large modules can be expensive, developers should only use the Module()
constructor when synchronous compilation is absolutely required; the asynchronous WebAssembly.compile()
method should be used at all other times.
var myModule = new WebAssembly.Module(bufferSource);
Module
ConstructorWebAssembly.Module.customSections()
Module
and string, returns a copy of the contents of all custom sections in the module with the given string name.WebAssembly.Module.exports()
Module
, returns an array containing descriptions of all the declared exports.WebAssembly.Module.imports()
Module
, returns an array containing descriptions of all the declared imports.Module
instancesAll Module
instances inherit from the Module()
constructor's prototype object — this can be modified to affect all Module
instances.
Module.prototype.constructor
WebAssembly.Module()
constructor.Module.prototype[@@toStringTag]
Module instances have no default methods of their own.
Specification | Status | Comment |
---|---|---|
WebAssembly JavaScript API The definition of 'WebAssembly.Module()' in that specification. | Draft | Initial draft definition. |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 57 | 16 | 522 | No | 44 | 11 |
customSections |
57 | 16 | 522 | No | 44 | 11 |
exports |
57 | 16 | 522 | No | 44 | 11 |
imports |
57 | 16 | 522 | No | 44 | 11 |
prototype |
57 | 16 | 522 | No | 44 | 11 |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | 57 | 57 | Yes1 | 522 | No | ? | 11 |
customSections |
57 | 57 | Yes1 | 522 | No | ? | 11 |
exports |
57 | 57 | Yes1 | 522 | No | ? | 11 |
imports |
57 | 57 | Yes1 | 522 | No | ? | 11 |
prototype |
57 | 57 | Yes1 | 522 | No | ? | 11 |
1. This feature is behind the Experimental JavaScript Features
preference.
2. Disabled in the Firefox 52 Extended Support Release (ESR).
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module