Contact emails
fbea...@chromium.org, to...@chromium.org
Explainer
https://github.com/wicg/user-preference-media-features-headers/blob/main/README.md
Specification
https://wicg.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>CSS
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
Developers can change the Sec-CH-Prefers-Color-Scheme client hint header value by emulating dark or light mode via DevTools in the Rendering panel.
Measurement
The kClientHintsPrefersColorScheme WebFeature tracks Sec-CH-Prefers-Color-Scheme client hint usage.
Risks
Interoperability and Compatibility
There are no particular compatibility risks.
Interoperability is still pending on other browser vendors replying. Support for Client Hints in general is not enthusiastic though.
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 (WICG proposal Issue: https://github.com/WICG/proposals/issues/30 with feedback from developers working for Facebook and Magento. 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)
Ergonomics:
N/A
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. https://wpt.fyi/results/client-hints.
Tracking bug
Link to entry on the Chrome Platform Status
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAPpwU5%2BYRbuQMWdwLC05wPzhv1%3DxNpC4t_uNRoFRqHkBc0Pyww%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAKXHy%3DdU9B0q69RPQ6CF4xz%3D-uZ_2YXrYUvAOpsPLpnAuh7cog%40mail.gmail.com.