This is a very simple example of using asm.js to generate wasm binary file.
math.js
: The source file, writing in asm.js.math.wast
: The s-expressions text format of WebAssembly.math.wasm
: The WebAssembly binary file.index.html
: The entry point of this example.
The math.js
exports two methods: add
and square
.
In the index.html
, the loadWebAssembly
method takes a url of .wasm
file and convert to a WebAssembly Instance.
- Start a web server.
- Use the browser that supports WebAssembly to open the
index.html
.
Binaryen WABT
math.js ---> math.wast ---> math.wasm