Skip to content

Commit

Permalink
Fix flickering on app load due to theme being loaded later
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rudolfs committed Sep 6, 2024
1 parent 560891d commit 6017c19
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<script>
// Avoid flickering on app start.
if (localStorage.getItem("theme") === "dark") {
document.documentElement.setAttribute("data-theme", "dark");
}
</script>
<meta charset="UTF-8" />
<link rel="icon" href="/radicle.svg" type="image/svg+xml" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
Expand Down

0 comments on commit 6017c19

Please sign in to comment.