From e0598787e0edeacf7225249c927a863ca657271d Mon Sep 17 00:00:00 2001 From: Dima Demakov Date: Mon, 27 Nov 2023 16:57:21 +0100 Subject: [PATCH] doc: remove flicker on page load on dark theme Theme applying logic get loaded and executed in async mode, so often there is a delay in applying the proper theme to a page which leads to flicker on dark theme. Resolved by moving critical logic to the page head PR-URL: https://github.com/nodejs/node/pull/50942 Reviewed-By: Moshe Atlow Reviewed-By: Claudio Wunder --- doc/api_assets/api.js | 6 ------ doc/template.html | 13 +++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/doc/api_assets/api.js b/doc/api_assets/api.js index 8b40042f85cbae..394b5ba990946c 100644 --- a/doc/api_assets/api.js +++ b/doc/api_assets/api.js @@ -24,12 +24,6 @@ ); } } - - if (mq.matches) { - document.documentElement.classList.add('dark-mode'); - } - } else if (storedTheme === 'dark') { - document.documentElement.classList.add('dark-mode'); } if (themeToggleButton) { diff --git a/doc/template.html b/doc/template.html index fb334852aba434..658c8d94cd0723 100644 --- a/doc/template.html +++ b/doc/template.html @@ -10,6 +10,19 @@ + __JS_FLAVORED_DYNAMIC_CSS__