ampproject / ampproject/amppackager

SSR all amp-img tags to img (not just the hero images)

Open
#465 6 comments 0 reactions 1 assignee Claimed by @jridgewell View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.