Investigate WebAssembly.instantiateStreaming
Closed this issue · 2 comments
juniorrojas commented
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.
juniorrojas commented
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;
}
juniorrojas commented