Skip to content

Commit

Permalink
Try to fix DOMContentLoaded race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
njt1982 committed Aug 15, 2023
1 parent a802f33 commit c81de72
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions public/js/darkmode.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
}
});

window.addEventListener("DOMContentLoaded", () => {
const initDarkMode = () => {
showActiveTheme(getPreferredTheme());

document
Expand All @@ -86,5 +86,10 @@
setTheme(theme);
showActiveTheme(theme, true);
});
});
};
if (document.readyState !== "loading") {
initDarkMode();
} else {
document.addEventListener("DOMContentLoaded", initDarkMode);
}
})();

0 comments on commit c81de72

Please sign in to comment.