use IIFE in app.html to prevent FOUC

This commit is contained in:
Danny Liu 2024-03-17 00:25:33 -07:00
parent 41cb6d7a54
commit a57586a2b7

View file

@ -8,6 +8,7 @@
<meta name="robots" content="noindex,nofollow" />
<script>
// On page load or when changing themes, best to add inline in `head` to avoid FOUC
(() => {
if (
localStorage.theme === 'light' ||
(!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: light)').matches)
@ -36,6 +37,7 @@
}
}
});
})();
</script>
%sveltekit.head%