Skip to content

src attribute of img inside picture should be set after img is appended to picture to avoid unnecessary requests #11357

Open
@CaseJnr

Description

@CaseJnr

Version

2.6.11

Reproduction link

https://codepen.io/CaseJnr/pen/VwvWbPE

Steps to reproduce

  1. Open the codepen link in safari

  2. Inspect the element

  3. Reduce the view width below 900px and refresh the page

  4. You will notice that both the red and blue image is requested.

  5. Comment out the vue instance and refresh the page.

  6. You will notice only the red image is requested (as expected).

What is expected?

Only the required picture resource is requested.

What is actually happening?

Both of the pictures resources are requested, causing redundant downloads.


In Safari, adding a vue instance to any page will cause redundant picture sources to be requested. The picture element will behave correctly if the vue instance is removed.

E.g.

<picture>
<source media="(max-width: 900px)" srcset="small.jpg">
<img src="large.jpg" alt="">
</picture>

By default, only the small.jpg should be requested when the view width is below 900px. However, if a vue instance is added to the page, then both the small.jpg and large.jpg are requested.

The mobile inspector shows the small.jpg request initiator as the page (expected). The large.jpg initiator is actually the vue instance.

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