Skip to content

Bug: Fallback image unnecessarily downloaded in <picture> element on Safari #35133

@bviale

Description

@bviale

When a element with a fallback image is rendered by React, Safari downloads both the fallback image and the correct image from the element. This issue occurs only in Safari and results in the fallback image being downloaded unnecessarily.

Reproduced on macOS Safari 18.6

React version: 19.2.0

Steps To Reproduce

  1. Add the following tags inside a React component JSX :
      <picture>
        <source
          media="(min-width:650px)"
          srcSet="https://www.w3schools.com/TAGS/img_pink_flowers.jpg"
        />
        <source
          media="(min-width:465px)"
          srcSet="https://www.w3schools.com/TAGS/img_white_flower.jpg"
        />
        <img
          src="https://www.w3schools.com/TAGS/img_orange_flowers.jpg"
          alt="Flowers"
        />
      </picture>
  1. Open the app on Safari
  2. Observe that 2 images are downloaded : the one corresponding to the screen size and the fallback image
  3. Move the element to the root index.html so it is rendered outside of React
  4. Observe that only the image corresponding to the screen size is downloaded

Link to code example:

https://codesandbox.io/p/sandbox/dreamy-swartz-rfm5wv

The current behavior

Image

The fallback image is being downloaded unnecessarily.

The expected behavior

Only one picture should be downloaded, just like with other browsers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions