ampproject / ampproject/amppackager
SSR all amp-img tags to img (not just the hero images)
- Dominant language
- Go
- Stars
- 141
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Description
@jridgewell's http://cl/327496988 (c/o #466) converts hero images from `amp-img` to `amp-img > img` and adds `link rel=preload`.
In addition, for SXG, we should convert *all* `amp-img`s on the page to `amp-img > img[loading=lazy]` (but not preload them). Thus, all images above the fold can be fetched and decoded before full layout, but at a lower priority than hero images.
Example: https://jsfiddle.net/Ln9yejr3/show
This is particular to SXG-optimized AMP, because `loading=lazy` isn't [implemented](https://caniuse.com/#feat=loading-lazy-attr) in all browsers that AMP targets, but it is implemented in almost all browsers that support [SXG](https://caniuse.com/#feat=sxg). (~3% of Chromium browsers are 73-75.)
As a precondition to this change, SXG-supporting AMP caches should remove the non-hero `img` tags when retransforming for unsigned use (which includes a higher fraction of non-loading=lazy-supporting browsers), so that the prerender network usage is the same as non-SXG AMP.
Moving discussion from https://github.com/ampproject/amphtml/pull/29025#discussion_r472493977. /cc @sebastianbenz @cramforce @jridgewell
Contributor guide
Assessment
This issue has not been assessed yet.