whois/template/static/js/util/setThemeBeforeRender.js
Elizabeth Hunt d25ec27fb1
Some checks failed
continuous-integration/drone/push Build is failing
initial commit by simponic-infra
2025-01-05 16:39:13 -08:00

12 lines
392 B
JavaScript

const preferredMode = window.matchMedia("(prefers-color-scheme: dark)").matches
? "DARK"
: "LIGHT";
// sets theme before rendering & jquery loaded to prevent flashing of uninitialized theme
// (ugly white background)
localStorage.setItem("theme", localStorage.getItem("theme") || preferredMode);
document.documentElement.setAttribute(
"data-theme",
localStorage.getItem("theme"),
);