Skip to content

amp-img ssr: don't generate sizes attribute #32644

@sebastianbenz

Description

@sebastianbenz

Problem

Server-side rendering a hero image can cause double download of the same image when using srcset but not sizes. The problem is: the amp-img extension in that case generates a viewport specific sizes attribute which might cause a re-download of the same image.

Steps to reproduce

Load https://lava-useful-horesradish.glitch.me/ in DevTools simulating a mobile device, e.g. G4. You can see that the image is downloaded twice:

Screenshot 2021-02-12 at 22 38 04

Suggested fix

Don't generate a sizes attribute for ssr'd img. There's no value in setting this anyway, as the user agent has already decided at this point in time which image to download.

//cc @patrickkettner @jridgewell

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions