Open dvtkrlbs opened 2 months ago
Sounds like a good idea. First we have to add a PR to web_sys
to support the API.
@maccesch from what I read it doesn't need any kind of client side feaute. Since everything only via headers. We just need the integration via axum since at first response server responds with critical hints and client retries the request.
For #101 we only need the server side part indeed because the client side is already handled. But even in that case we're probably interested in being able to read it on the client as well.
For a general purpose client hints function we definitely need client side. Pages should work the same as much as possible between being rendered on the server or on the client.
This is the client API: https://developer.mozilla.org/en-US/docs/Web/API/User-Agent_Client_Hints_API
I made a PR for web_sys: https://github.com/rustwasm/wasm-bindgen/pull/3989
@maccesch these are the user agent client hints api and I was mostly considerign User preference media features client hints css features where you can get for example Sec-CH-Prefers-Reduced-Motion, Sec-CH-Prefers-Color-Scheme. These already have client side apis. But yeah for the user agent ones that makes sense.
Yes, but while we're at it we might as well do it right, don't you agree?
As far as I read it you're talking about a subset but when we implement this API I'd rather do it all at once.
@dvtkrlbs I finally fully understood what you meant with existing client APIs. The Sec-CH-Prefers-Color-Scheme is now implemented.
@dvtkrlbs I finally fully understood what you meant with existing client APIs. The Sec-CH-Prefers-Color-Scheme is now implemented.
Thank you very much
Client hints currently experimental. Maybe we can implement some features of it using a feature flag. Especially the Sec-CH-Prefers-Color-Scheme header could be useful to setup dark mode on the server to prevent flash on non dark mode content.