From bc705ff19dfb8a65a48d844e255164e704915cf0 Mon Sep 17 00:00:00 2001 From: saltycrys <73420320+saltycrys@users.noreply.github.com> Date: Mon, 16 Nov 2020 01:51:18 +0100 Subject: [PATCH] Switch theme on `DOMContentLoaded` event instead of `load` event This doesn't fix the issue of the bright flash but makes it shorter. The `load` event is fired when the page and all resources are fully loaded while the `DOMContentLoaded` event is fired when initial HTML document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading. --- assets/js/themes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/themes.js b/assets/js/themes.js index c600073d..8f209ed3 100644 --- a/assets/js/themes.js +++ b/assets/js/themes.js @@ -22,7 +22,7 @@ window.addEventListener('storage', function (e) { } }); -window.addEventListener('load', function () { +window.addEventListener('DOMContentLoaded', function () { window.localStorage.setItem('dark_mode', document.getElementById('dark_mode_pref').textContent); // Update localStorage if dark mode preference changed on preferences page update_mode(window.localStorage.dark_mode);