Files
ResumeSite/site/public/theme-init.js
T
cesnimda 743cce306b
CI / quality (push) Has been cancelled
CI / e2e (push) Has been cancelled
CI / lighthouse (push) Has been cancelled
CI / relay (push) Has been cancelled
CI / images (push) Has been cancelled
docs: finalise PROJECT_STATUS + TODO; lint public browser script
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-04 06:24:12 +02:00

19 lines
715 B
JavaScript

/*
No-flash theme init (external so a strict CSP can use script-src 'self' with no
inline hash). Loaded render-blocking in <head>, runs before first paint: marks
that JS is available (reveal animations are gated behind html.js) and applies the
stored or system theme. First visit follows the system; once set, the choice persists.
*/
(function () {
document.documentElement.classList.add('js');
try {
var t = localStorage.getItem('theme');
if (t !== 'light' && t !== 'dark') {
t = window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';
}
document.documentElement.dataset.theme = t;
} catch {
document.documentElement.dataset.theme = 'dark';
}
})();