DEV Community

Discussion on: Any reason for not using loading="lazy" attribute?

Collapse
 
ben profile image
Ben Halpern

I think conceivably if there is an image you know you want showing up ASAP, you'd want to set loading="eager" on those ones..... But for the most part, the lazy images already above the fold will be loading more or less instantly.

All else equal, lazy is the way to go, but if we see that some images are being wrongly deferred, we could instruct the browser otherwise.

Collapse
 
pp profile image
Paweł Ludwiczak

Then I kinda wonder why loading="lazy" isn't the default behavior for browsers (those that support it). It sounds like it's the way to go in 99% of the cases. And for the rest of the cases, you set loading="eager" or whatever is appropriate to overwrite default behavior.

Collapse
 
andericsilva profile image
Anderson Ismael Couto da Silva

it is costly for browsers to calculate the current position of each image and cross-reference the scrollbar data, in addition to doing such a thing they would break various image-based tracker mechanisms

Thread Thread
 
moopet profile image
Ben Sinclair

That second part sounds like a net win to me.