We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6ec2398 commit 39c33ccCopy full SHA for 39c33cc
packages/npm-packages/ruby-wasm-wasi/src/browser.script.ts
@@ -12,7 +12,16 @@ export const main = async (pkg: { name: string; version: string }) => {
12
13
globalThis.rubyVM = vm;
14
15
- runRubyScriptsInHtml(vm);
+ // Wait for the text/ruby script tag to be read.
16
+ // It may take some time to read ruby+stdlib.wasm
17
+ // and DOMContentLoaded has already been fired.
18
+ if (document.readyState === "loading") {
19
+ document.addEventListener("DOMContentLoaded", () =>
20
+ runRubyScriptsInHtml(vm)
21
+ );
22
+ } else {
23
+ runRubyScriptsInHtml(vm);
24
+ }
25
};
26
27
const runRubyScriptsInHtml = async (vm) => {
0 commit comments