Contact emails
fbea...@chromium.org, to...@chromium.org
Explainer
https://github.com/tomayac/user-preference-media-features-headers/blob/main/README.md
Specification
https://tomayac.github.io/user-preference-media-features-headers/#sec-ch-prefers-color-scheme
API spec
Yes
Summary
The Sec-CH-Prefers-Color-Scheme client hint is modeled after the prefers-color-scheme user preference media feature as defined in Media Queries Level 5.
Blink component
Blink>DarkMode
Motivation
CSS media queries, and specifically user preference media features like prefers-color-scheme, have a potentially significant impact on the amount of CSS that needs to be delivered by a page, and on the experience the user is going to have when the page loads.
It is a best practice to not load CSS for the particular non-matching color scheme in the critical rendering path, and instead to initially only load the currently relevant CSS. One way of doing so is via <link media>. However, high-traffic sites like Google Search that wish to honor user preference media features like prefers-color-scheme and that inline CSS for performance reasons, need to know about the preferred color scheme (or other user preference media features respectively) ideally at request time, so that the initial HTML payload already has the right CSS inlined.
TAG review
https://github.com/w3ctag/design-reviews/issues/632
TAG review status
Pending
Demo link
https://sec-ch-prefers-color-scheme.glitch.me/
Debuggability
Measurement
The kClientHintsPrefersColorScheme WebFeature will track Sec-CH-Prefers-Color-Scheme client hint usage.
Risks
Interoperability and Compatibility
Signals from other implementations (Gecko, WebKit):
Gecko: Pending (https://github.com/mozilla/standards-positions/issues/526)
WebKit: Pending (https://lists.webkit.org/pipermail/webkit-dev/2021-May/031856.html)
Web / Framework developers: Positive (Twitter: https://twitter.com/kilianvalkhof/status/1392404416335056896. The proposal was initially discussed in https://github.com/w3c/csswg-drafts/issues/4162 and received positive feedback via 16 Likes and 3 supportive comments: https://github.com/w3c/csswg-drafts/issues/4162#issuecomment-621047333, https://github.com/w3c/csswg-drafts/issues/4162#issuecomment-631400330, and https://github.com/w3c/csswg-drafts/issues/4162#issuecomment-645742958)
Activation:
Developers will include Sec-CH-Prefers-Color-Scheme in the response headers Accept-CH and Critical-CH to let the browser know that they’re interested in the preferred color scheme. If supported, the request header Sec-CH-Prefers-Color-Scheme will be populated with the appropriate value.
Is this feature fully tested by web-platform-tests?
Yes. We will add new tests for these proposed changes at https://wpt.fyi/results/client-hints.
Flag name
enable-experimental-web-platform-features
Tracking bug
Link to entry on the Chrome Platform Status
Contact emails
fbea...@chromium.org, to...@chromium.org
Explainer
https://github.com/tomayac/user-preference-media-features-headers/blob/main/README.md
Specification
https://tomayac.github.io/user-preference-media-features-headers/#sec-ch-prefers-color-scheme
API spec
Yes
Summary
The Sec-CH-Prefers-Color-Scheme client hint is modeled after the prefers-color-scheme user preference media feature as defined in Media Queries Level 5.
Blink component
Blink>DarkMode