Skip to content

<img sizes=auto> triggers wasteful fetches when hiding/removing the image #12712

Description

@noamr

What is the issue with the HTML Standard?

When reading the current spec around <img sizes=auto>, it seems like both setting an image's display to none, as well as removing the image from the DOM, would trigger re-parsing of the sizes attribute and potentially triggering a fetch.

See https://gist.github.com/noamr/a201b894d0ac5ceea091874e72092023

  • We have 5 images in a DIV with a srcset and sizes, that are initially rendered in a size different from the default
  • We then remove the DIV (or set it to display:none)
  • According to the spec (and current blink), those 5 images would trigger reloading, re-fire the load event, etc.

Interestingly, Firefox does not exhibit this behavior (sizes=auto is not implemented in Safari).

This behavior seems extremely wasteful - if an image is removed/un-rendered, we should probably keep its currentSrc rather than switch it to the fallback, or at least not trigger a reload in that case.

See relevant chromium bug.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions