Open
Description
Currently the UA "remembers" which DPR variant it picks when making a request and then uses said value to scale the received asset before it's displayed - e.g. if a 2x selector is used, then the image is automatically scaled down by same factor before its displayed.
However, there are cases where what the client chooses, and what comes back (from server, cache, service worker, etc), are not the same:
- Client requests a 2x asset, but server/cache does not have it available and wants to return a 1x asset. Today, this would result in an incorrectly scaled asset once displayed.
- ServiceWorker intercepts requests and goes on to automate/rewrite fetches to account for device DPR - there is no way for SW to communicate to UA the DPR value of the fetched asset. This is also an issue if SW synthesizes a response - e.g. user is offline, and only a lower resolution asset is available.
- If the developer fetches an arbitrary Blob/ArrayBuffer (via XHR or other means), it would be nice to provide a JS API where the pixel density can be set/updated + queried on the element.
To address above use cases, we need two things:
- JS API to query and set pixel density on an image element - e.g
img.density = 2.0
, or some such. - Ability to initialize (and override UA default) image pixel density via an HTTP header - e.g.
Content-DPR: 3.0
indicates that returned image response should be processed as a 3x asset.- This case is important for ServiceWorker and Client-Hints. The
Content-DPR
header is spec'ed in CH: https://tools.ietf.org/html/draft-grigorik-http-client-hints-02#section-4.1 and we have a prototype implementation in Chrome.
- This case is important for ServiceWorker and Client-Hints. The
Metadata
Assignees
Labels
No labels