Skip to content

Commit d7bda26

Browse files
ledsunkateinoigakukun
authored andcommitted
Use WebAssembly.compileStreaming
With WebAssembly.compileStreaming, compilation completes 40 ms faster than WebAssembly.compile.
1 parent 3e371ec commit d7bda26

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

packages/npm-packages/ruby-wasm-wasi/src/browser.script.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { DefaultRubyVM } from "./browser";
22

33
export const main = async (pkg: { name: string; version: string }) => {
4-
const response = await fetch(
4+
const response = fetch(
55
`https://cdn.jsdelivr.net/npm/${pkg.name}@${pkg.version}/dist/ruby+stdlib.wasm`,
66
);
7-
const buffer = await response.arrayBuffer();
8-
const module = await WebAssembly.compile(buffer);
7+
const module = await WebAssembly.compileStreaming(response);
98
const { vm } = await DefaultRubyVM(module);
109

1110
vm.printVersion();

0 commit comments

Comments
 (0)