Commit 9fb233b
index: inline pre-paint script to prevent theme flash
Reads the stored theme preference synchronously in the document
head and sets theme_night on <html> before any CSS resolves, so
dark-mode users don't see a light-theme flash while Vite loads
the main bundle. Read-only and wrapped in try/catch; the full
theme module still owns writes and listeners.
If localStorage access throws (sandboxed iframes, storage disabled,
some file:// contexts), a nested try/catch still applies
theme_night based on prefers-color-scheme alone, so OS-dark users
also get the correct first paint without a late flip when
lib/theme.ts boots.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent d2ecf85 commit 9fb233b
1 file changed
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
33 | 50 | | |
34 | 51 | | |
35 | 52 | | |
| |||
0 commit comments