From 529c5e343d3de23fea95349b583c8d7c875d3cb7 Mon Sep 17 00:00:00 2001 From: Joe <33972521+hnb-ku@users.noreply.github.com> Date: Fri, 24 Jun 2022 17:39:26 +0800 Subject: [PATCH] FIX: Defer removing the splash screen until the window load event fires take 2 (#17230) There's an obscure bug where really slow devices end up removing the splash screen before they're finished parsing all of the Discourse assets. This PR won't impact fast devices but should hopefully prevent the premature removal of the splash on super slow devices. --- app/assets/javascripts/discourse/app/app.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/app/app.js b/app/assets/javascripts/discourse/app/app.js index 3ff0205cccc..be305596c42 100644 --- a/app/assets/javascripts/discourse/app/app.js +++ b/app/assets/javascripts/discourse/app/app.js @@ -82,8 +82,14 @@ const Discourse = Application.extend({ }); }); - // The app booted. Remove the splash screen - document.querySelector("#d-splash")?.remove(); + window.addEventListener( + "load", + () => { + // The app booted. Remove the splash screen + document.querySelector("#d-splash")?.remove(); + }, + { once: true } + ); }, _registerPluginCode(version, code) {