WebAssembly.Module.imports()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since October 2017.

The WebAssembly.Module.imports() static method returns an array containing descriptions of all the declared imports of the given Module.

Syntax

js
WebAssembly.Module.imports(module)

Parameters

Return value

An array containing objects representing the imported functions of the given module.

Exceptions

If module is not a WebAssembly.Module object instance, a TypeError is thrown.

Examples

Using imports

The following example compiles a loaded Wasm module and queries the module's imports.

See imports.html source code and live version.

js
WebAssembly.compileStreaming(fetch("simple.wasm")).then((mod) => {
  const imports = WebAssembly.Module.imports(mod);
  console.log(imports[0]);
});

The console log displays the following description for the imported module:

js
{ module: "my_namespace", name: "imported_func", kind: "function" }

Specifications

Specification
WebAssembly JavaScript Interface
# dom-module-imports

Browser compatibility

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
imports() static method

Legend

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

Full support
Full support

See also