-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Support of imagesrcset and imagesizes attributes for preloading images #29302
Comments
/cc @ampproject/wg-caching |
At first glance, this seems fine. Probably just not included because these attributes are newer than the creation of that rule. I think before allowing this we need to figure out what (if any) changes to cache-side transforms are necessary. FYI @amaltas who has done some work in this space. |
Discussed at wg-caching standup. @dvoytenko @nainar Does this seem like something we should do? (We're guessing "yes" for AMP First, but wanted confirmation.) Assigning P3 conservatively, but open to change. Other details:
|
I have no reservations about supporting this. However, we need to correctly rewrite these links on cache. So we can't validate these tags until the cache processes them safely. |
It looks like cache processes it correctly, so we should be all good supporting it in the validator. |
Bumping priority per discussion with @dvoytenko. |
Adds validator support for the two new `<link rel=preload>` attributes, and adds srcset URL rewriting for imagesrcset. Fixes ampproject/amphtml#29302 PiperOrigin-RevId: 325359140
Adds validator support for the two new `<link rel=preload>` attributes, and adds srcset URL rewriting for imagesrcset. Fixes ampproject/amphtml#29302 PiperOrigin-RevId: 325359140
actually this was fixed in #29830 |
Describe the new feature or change to an existing feature you'd like to see
Support of
imagesrcset
andimagesizes
attributes for<link rel="preload">
based on the HTML standard here: https://html.spec.whatwg.org/multipage/semantics.html#attr-link-imagesrcsetDescribe alternatives you've considered
We've tried simply using the
media
attribute which works in some situations, but causes overly complex HTML when more control is needed, and in other cases I don't think it's capable of replicating the missing attributes as per the examples below.In our first example, we have 4 breakpoints, each with their own art direction and the ability to serve 2x and 3x resolution variants. This is possible to do with the
media
attribute but it does mean 12link
tags need to be printed out in the page, rather than 4 ifimagesrcset
was available, and we'd like to avoid unnecessary bloat/complexity if possible. Here's the example of the code that works, but is invalid in AMP scenariosIn our second example, which includes an image that displays at different widths of the screen depending upon the breakpoint and relies on the
sizes
attribute to calculate this, I don't know of an alternative for preloading efficiently. Take the following code as an examplethis would then be used for the following
img
tag:N.B. I'm aware that the
sizes
attribute is not needed in this example if usingamp-img
due initially to #20968Additional context
Looking through the validator files, it seems that these attributes would just need adding to an allowlist somewhere around
amphtml/validator/validator-main.protoascii
Line 291 in c1c08fe
The text was updated successfully, but these errors were encountered: