From 526115f11a9313c079c230c1d7359c865607115e Mon Sep 17 00:00:00 2001 From: Joe <33972521+hnb-ku@users.noreply.github.com> Date: Sat, 25 Jun 2022 12:59:16 +0800 Subject: [PATCH] FIX: Defer removing the splash screen until the window load event fires take 3 (#17238) We currently remove the splash screen once Discourse starts booting. This can be an issue on very slow devices, which can take up to 6 seconds. This PR ensures that we don't remove the splash until the browser has finished parsing all of the site's assets. It won't impact fast devices. Internal topic /t/65378/60 --- app/assets/javascripts/discourse/app/app.js | 10 ++++-- app/views/common/_discourse_splash.html.erb | 33 +++++++++--------- public/images/preloader.svg | 37 +++++++++------------ 3 files changed, 39 insertions(+), 41 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) { diff --git a/app/views/common/_discourse_splash.html.erb b/app/views/common/_discourse_splash.html.erb index 747d5352d9d..08b92b65f53 100644 --- a/app/views/common/_discourse_splash.html.erb +++ b/app/views/common/_discourse_splash.html.erb @@ -2,15 +2,20 @@
- - - - - + + + + +