Skip to main content

Preferences

The theme is a preference in the path. A theme cookie of light or dark has this page rewritten to a copy that was prerendered with data-theme on <html>; without one, the page follows the OS.

Choosing writes the cookie and refreshes the route. The page that comes back already has the attribute, so the switch is one attribute change. Nothing runs on the client to work out the theme, so there is nothing to flash.

The test that matters

Pick Dark, then reload the page — hard, with the cache cleared if you like. The first frame is dark. The HTML arrived with data-theme="dark" and the stylesheet keys off it, so at no point does the browser have a page without the answer.

Every page on this site has three prerendered copies for this: no theme, light and dark. The build lists them as /en/-/-/demos/prefs, /en/theme~light/-/demos/prefs and /en/theme~dark/-/demos/prefs.

Inspector

Address bar
/en/-/-/demos/prefs
Rendered as
/en/-/-/-/-/demos/prefs
Locale
en
Preferences
{}
Flags
{}