Investigate WebAssembly.instantiateStreaming
juniorrojas opened this issue · comments
Currently using WebAssembly.instantiate
.
async function loadWasm() {
const response = await fetch("algovivo.wasm");
const bytes = await response.arrayBuffer();
const wasm = await WebAssembly.instantiate(bytes);
return wasm.instance;
}
but WebAssembly.instantiateStreaming
might be a better option.
No need to do response.arrayBuffer()
if we use WebAssembly.instantiateStreaming
.
async function loadWasm() {
const wasm = await WebAssembly.instantiateStreaming(
await fetch("algovivo.wasm")
);
return wasm.instance;
}