Skip to content

Commit 3c3ba7b

Browse files
committed
chore: Fix FOUC
1 parent ce757c9 commit 3c3ba7b

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/index.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<link rel="icon" type="image/svg+xml" href="@/assets/logo.png" />
77
<title>TypeScript Exercises</title>
8-
<script src="./theme.ts" fetchpriority="high"></script>
9-
<script type="module" src="./Page.tsx" async></script>
108
<style>
119
:root {
1210
--background: hsla(0 0% 100%);
@@ -18,8 +16,15 @@
1816
background-color: var(--background);
1917
}
2018
</style>
19+
<script type="module" src="./Page.tsx" async></script>
2120
</head>
2221
<body>
22+
<script>
23+
const pref = localStorage.getItem('theme');
24+
if (pref === 'light') document.body.classList.add('light');
25+
else document.body.classList.add('dark');
26+
setTimeout(() => document.body.classList.add('duration-400'), 0);
27+
</script>
2328
<div id="root" class="overflow-x-hidden"></div>
2429
</body>
2530
</html>

src/theme.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)