WASM - Simplest Thing That Works (STTWs)
2026W14-3
Simplest zig wasm
export fn add(a: i32, b: i32) i32 { return a + b;}zig build-exe add.zig -target wasm32-freestanding -fno-entry -rdynamic<!doctype html><html> <body> <script> const request = new XMLHttpRequest() request.open('GET', 'add.wasm') request.responseType = 'arraybuffer' request.send() request.onload = function () { WebAssembly.instantiate(request.response, { env: {} }).then((result) => { const add = result.instance.exports.add console.log(add(3, 5)) // Outputs 8 }) } </script> </body></html>run
python -m http.server