The default function to load images first copies data-src to src, followed by data-srcset to srcset.
This means the image tag gets updated twice: first with a src-attribute and then with a srcset-attribute.
The result is Safari loading the image defined in the src-attribute and then also loading the best-suited image from the srcset, since for a short moment it is a default image tag before it becomes an image tag with a srcset.
I have tested this with Chrome and Safari; Safari was the only one to do this, but other browsers could be affected as well.
Solution: Change the order in which the attributes are updated, so that srcset is defined before src.
The default function to load images first copies
data-src
tosrc
, followed bydata-srcset
tosrcset
. This means the image tag gets updated twice: first with a src-attribute and then with a srcset-attribute. The result is Safari loading the image defined in the src-attribute and then also loading the best-suited image from the srcset, since for a short moment it is a default image tag before it becomes an image tag with a srcset.I have tested this with Chrome and Safari; Safari was the only one to do this, but other browsers could be affected as well.
Solution: Change the order in which the attributes are updated, so that
srcset
is defined beforesrc
.