web: Fix compatibility with Rocket Loader
Cloudflare's Rocket Loader script [prevents the DOMContentLoaded event from firing](https://dev.to/hollowman6/solution-to-missing-domcontentloaded-event-when-enabling-both-html-auto-minify-and-rocket-loader-in-cloudflare-5ch8), which was preventing Ruffle's public API from initializing. Work around this by also listening for the `load` event. Fixes #2254 and #6583.
This commit is contained in:
parent
3dbde841df
commit
e8d5274a18
|
@ -83,7 +83,9 @@ export class PublicAPI {
|
|||
}
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
window.addEventListener("DOMContentLoaded", this.init.bind(this));
|
||||
// Cloudflare Rocket Loader interferes with the DOMContentLoaded event,
|
||||
// so we listen for readystatechange instead
|
||||
document.addEventListener("readystatechange", this.init.bind(this));
|
||||
} else {
|
||||
window.setTimeout(this.init.bind(this), 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue