Repository navigation
Prevent theme flashes during startup - #719
Merged
Merged
Conversation
bgentry
force-pushed
the
bg/prevent-theme-flash
branch
from
October 26, 2026 01:19
b774a3a to
c058ab0
Compare
The initial HTML renders before the theme provider mounts, which waits for the features request. Dark mode can show a white page while the styles, JavaScript, and API response load. Apply the saved or system theme in a synchronous head script and paint the matching page background before external assets load. Fall back to the system preference when browser storage is unavailable, and let the existing theme provider continue managing subsequent changes.
bgentry
force-pushed
the
bg/prevent-theme-flash
branch
from
October 26, 2026 01:25
c058ab0 to
63ea086
Compare
bgentry
marked this pull request as ready for review
October 26, 2026 01:27
bgentry
enabled auto-merge (squash)
October 26, 2026 01:27
brandur
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apply the saved light/dark preference or system theme in the HTML head before external styles and JavaScript load. The page currently waits for React and the features API before mounting the theme provider, so a dark page can briefly render with a white background.
Set the initial document color scheme and matching background immediately, using the system preference if browser storage is blocked. The existing theme provider continues to handle theme changes after startup.
The comparison uses cold loads in dark mode with 200 ms network latency, 8 Mbps download throughput, and a 1.2-second features response delay. Both local previews use the same production assets and an empty jobs response.