Home > Blockchain >  <img> - loading='lazy' vs Intersection Observer?
<img> - loading='lazy' vs Intersection Observer?

Time:07-04

I'm building a React app which is very image heavy, all from API calls. I've got loading='lazy' on all of them but it got me wondering if more can be done? I know you can achieve a similar result using intersection observers and only rendering them when in view.

My question is better/are there any further benefits to implementing intersection observers, or will it be a waste of time since loading='lazy' does enough?

Thanks!

CodePudding user response:

They do the same, if you want to load the image whenever it enters the viewport, Intersection Observer Give more control, For example, may you want to load the image when the image is at bottom of the viewport by let's say 100px, or you may want to do another action with the image beside be loaded.

  • Related