Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knowing DPR before calling images #71

Closed
karlcow opened this issue Mar 9, 2017 · 2 comments
Closed

Knowing DPR before calling images #71

karlcow opened this issue Mar 9, 2017 · 2 comments

Comments

@karlcow
Copy link

karlcow commented Mar 9, 2017

@igrigorik During a discussion with a big Web site, they had this context.

  1. They send different image resolutions to different devices.
  2. They need to know it before the image call (so at the initial HTML request)

window.devicePixelRatio is not working and client Hints for Image HTTP Request is too late. I guess they built the URI in the template on the server side at the initial request.

Do you think client hints would be able to address this use case?

@ejthurgo
Copy link

ejthurgo commented Mar 9, 2017

Client Hints plans to solve exactly this. DPI is relatively easy to ascertain, however image size is much more difficult because the browser's look-ahead pre-parser wants to start downloading images before it's loaded CSS (i.e. before it knows how big the image needs to be).
Your best bet for now is to use picture/srcset and request image sizes/dpi based on CSS style media queries (which are based on viewport width), which is definitely an improvement on UA sniffing.

@igrigorik
Copy link
Owner

@karlcow thanks for the feedback!

PTAL at the discussions in httpwg/http-extensions#306 and httpwg/http-extensions#307... we're working towards a solution to enable CH signals on the navigation requests there, which will cover the use case above.

(closing this, let's continue on httpwg issues linked above)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants