ApoorvSaxena / ApoorvSaxena/lozad.js

Attribute-updating order in load() results in Safari loading images twice

Ouverte
#99 1 commentaire 2 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
JavaScript
Étoiles
7.5k
Forks
435
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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`.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.