| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/WebAssembly/Reference/JavaScript_interface/instantiate_static | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2017 10.
* Some parts of this feature may have varying levels of support.
WebAssembly.instantiate() WebAssembly . overloads .
ArrayBuffer WebAssembly . Promise WebAssembly.Module WebAssembly.Instance .WebAssembly.Module Module Instance Promise . overload Module . :
: wasm . , WebAssembly.instantiateStreaming () . ArrayBuffer .
Promise<ResultObject> WebAssembly.instantiate(bufferSource, importObject);
ResultObject Promise :
module: WebAssembly WebAssembly.Module . Module postMessage() cached in IndexedDB .instance: Exported WebAssembly functions WebAssembly.Instance .TypeError .WebAssembly.CompileError, WebAssembly.LinkError WebAssembly.RuntimeError reject.Promise<WebAssembly.Instance> WebAssembly.instantiate(module, importObject);
A Promise that resolves to an WebAssembly.Instance object.
TypeError .WebAssembly.CompileError, WebAssembly.LinkError, or WebAssembly.RuntimeError, depending on the cause of the failure.
promise WebAssembly.CompileError, WebAssembly.LinkError WebAssembly.RuntimeError reject.Note: instantiate() WebAssembly.instantiateStreaming () .
fetch WebAssembly WebAssembly.instantiate () JavaScript WebAssembly . Instance Exported WebAssembly function .
var importObject = {
imports: {
imported_func: function (arg) {
console.log(arg);
},
},
};
fetch("simple.wasm")
.then((response) => response.arrayBuffer())
.then((bytes) => WebAssembly.instantiate(bytes, importObject))
.then((result) => result.instance.exports.exported_func());
: GitHub index.html ( ).
(GitHub index-compile.html ). WebAssembly.compileStreaming () simple.wasm postMessage() worker .
var worker = new Worker("wasm_worker.js");
WebAssembly.compileStreaming(fetch("simple.wasm")).then((mod) =>
worker.postMessage(mod),
);
(wasm_worker.js ) . WebAssembly.instantiate () .
var importObject = {
imports: {
imported_func: function (arg) {
console.log(arg);
},
},
};
onmessage = function (e) {
console.log("module received from main thread");
var mod = e.data;
WebAssembly.instantiate(mod, importObject).then(function (instance) {
instance.exports.exported_func();
});
};
| Specification |
|---|
| WebAssembly JavaScript Interface # dom-webassembly-instantiate |
This page was last modified on 2026 7 15 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |