How to load images dynamically (or lazily) when users scroll them into view with HTML?

Spread the love

To load images dynamically (or lazily) when users scroll them into view with HTML, we set the loading attribute.

For instance, we write

<img src="http://picsum.com/640/360" loading="lazy" />

to add an img element with the loading attribute set to lazy to make the image lazy load.

Leave a Reply

Your email address will not be published. Required fields are marked *