Search code examples
assemblybrowserlow-levelwebassembly

What is a WebAssembly (Wasm) module?


Was reading the MDN docs regarding Wasm. They used the term WASM module quite a few times. Their definition was the following:

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. To instantiate the module, call the secondary overload of WebAssembly.instantiate().

I couldn't quite understand the meaning of this. Is a web assembly module simply a Wasm file or is it something else?


Solution

  • WebAssembly is a low-level form of code that can be executed within modern browsers. In order to execute this code the browser must compile it, although because it is low-level, this compilation is relatively fast and simple when compared to JavaScript.

    The WebAssembly APIs separate the compilation step from the instantiation and execution step. Therefore, the WebAssembly module is a compiled version of your WebAssembly code (which is the wasm file you refer to) that is ready for instantiation and execution.