Categories
HTML

How to load images dynamically or lazily when users scrolls them into view with HTML?

Spread the love

Sometimes, we want to load images dynamically or lazily when users scrolls them into view with HTML.

In this article, we’ll look at how to load images dynamically or lazily when users scrolls them into view with HTML.

How to load images dynamically or lazily when users scrolls them into view with HTML?

To load images dynamically or lazily when users scrolls them into view with HTML, we can set the loading attribute to lazy.

For instance, we write

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

to set the loading attribute to lazy.

Then the image will be loaded only when it’s visible.

Conclusion

To load images dynamically or lazily when users scrolls them into view with HTML, we can set the loading attribute to lazy.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.