Skip to content

Commit 402e921

Browse files
committed
Parallelize stdlib loading
1 parent 5d8241c commit 402e921

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/js-executor/index.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export default class JsExecutor {
197197
"new URL(\"skiko.wasm\",import.meta.url).href",
198198
`'${API_URLS.SKIKO_WASM(version)}'`
199199
))
200-
.then(async skikoCode =>
200+
.then(skikoCode =>
201201
executeJs(
202202
this.iframe.contentWindow,
203203
skikoCode,
@@ -214,13 +214,16 @@ export default class JsExecutor {
214214
'Content-Type': 'text/javascript',
215215
}
216216
}).then(script => script.text())
217-
.then(script => script.replace(
218-
"new URL('./stdlib.wasm',import.meta.url).href",
219-
`'${API_URLS.STDLIB_WASM(hash)}'`
220-
).replace(
221-
"(extends) => { return { extends }; }",
222-
"(extends_) => { return { extends_ }; }"
223-
))
217+
.then(script =>
218+
// necessary to load stdlib.wasm before its initialization to parallelize
219+
// language=JavaScript
220+
(`const stdlibWasm = fetch('${API_URLS.STDLIB_WASM(hash)}');\n` + script).replace(
221+
"new URL('./stdlib.wasm',import.meta.url).href",
222+
"stdlibWasm"
223+
).replace(
224+
"(extends) => { return { extends }; }",
225+
"(extends_) => { return { extends_ }; }"
226+
))
224227
.then(stdlibCode =>
225228
executeWasmCodeWithSkiko(
226229
this.iframe.contentWindow,

0 commit comments

Comments
 (0)