JavaScript image lazy loading library that works based on src attribute



There are lots of libraries that use data- kind of attributes to specify the images. I’m looking for one that:

  • doesn’t need any extra parameter except of class or even better a chosen selector provided to the library
  • works with both src parameter of <img> and background-image CSS of other elements
  • loads images based on screen scroll, either right when you scroll onto them or a bit earlier, I assume using a DOM observer
  • as a bonus, it could support videos too, but not a necessity

Examples of elements it should cover:

<img src="some/file.webp"  alt="" />
<div some/file.webp');"  />
<div some/file.webp') repeat-x fixed;"  />



Source link

Related Posts

About The Author

Add Comment