Skip to content

Commit 6017c19

Browse files
committed
Fix flickering on app load due to theme being loaded later
We read the theme before any of the svelte code is loaded. The benefit is that it is executed first and there's no flickering if the stored theme differs from the initial theme that is set in the design system. The drawback is that this code isn't type-checked and will need to be updated manually if we change the theme switching code in Svelte.
1 parent 560891d commit 6017c19

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
<!doctype html>
22
<html lang="en">
33
<head>
4+
<script>
5+
// Avoid flickering on app start.
6+
if (localStorage.getItem("theme") === "dark") {
7+
document.documentElement.setAttribute("data-theme", "dark");
8+
}
9+
</script>
410
<meta charset="UTF-8" />
511
<link rel="icon" href="/radicle.svg" type="image/svg+xml" />
612
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

0 commit comments

Comments
 (0)