Skip to content

I2D: Deprecation of amp-img component #29786

@rbeckthomas

Description

@rbeckthomas

Summary

The purpose of this document is to describe how we can turn down the usage of the amp-img component in future amp documents.

Design document

Motivation

The amp-img component was primarily created in order to allow for lazy-loading of images in amp pages in order to improve page performance. At the time the native html img tag did not allow for this which necessitated the creation of a custom extension.

Today however, the native img tag does allow for lazy loading through the use of the loading attribute. As a result the amp-img extension is no longer needed to achieve the performance improvements for which it was originally created.
Because of this the amp-img extension will need to be constantly updated in order to maintain feature parity with the native html img tag or risk obsolescence.

In the long term we would like to turn down the use of amp-img in new amp documents, instead allowing developers to use the native html img tag with the loading attribute set to lazy in order to achieve these results. This would remove the burden on amp contributors to constantly maintain feature parity and will additionally allow developers to create simple documents without needing to learn the usage of an extra amp extension.
Before the deprecation of amp-img several features will need to be implemented in the current amp-img and the current caching system in order to maintain the level functionality which is afforded to us by the use of amp-img.

The two features required are support for native sizing and support for the blurry image placeholder.

Native Sizing
Currently we support the usage of the native sizing element if a flag is passed through the amp-img component. In order to ease the transition to native image components we will need to change this flag so that using the native sizing is the default behavior and using the amp-img sizing is done only through the flag.

Blurry Image Placeholder
One of the features which amp-img provides which cannot be replicated by native image is the blurry image placeholder. As a result, the best way to maintain this feature after transitioning to native image, will be to include this as a part of the cache transform for images. This change will require coordination with the conduit team.

Additional context

One of the primary challenges we will face with this deprecation is that we will be inherently and intentionally making the behavior of images in amp pages slightly worse. The two main features which will be impacted are image loading behavior and Content Layout Shifting. Due to the way in which native image is implemented there is no way currently to prevent the CLS which will occur once amp-img is deprecated, therefore we will need to very carefully consider how much CLS we are willing to allow in AMP pages and do research into the extent of this problem.

Launch tracker

/cc @ampproject/wg-approvers

Metadata

Metadata

Assignees

No one assigned

    Labels

    INTENT TO DEPRECATEProposes deprecating an existing AMP feature.WG: Caching: TriagedInitial triage from wg-caching complete. Remove label if new input required.WG: caching

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions