Skip to content

Latest commit

 

History

History
27 lines (13 loc) · 842 Bytes

File metadata and controls

27 lines (13 loc) · 842 Bytes

ImgLazyLoadingJavascript

A pure javascript way to lazy load images without a server can be run by just dropping example html file into browser.

Works by getting the image tags which have a data-src tag instead of a src tag on them, then detecting the boundaries hit the scroll position + window.innerHeight and setting src on the image causing the iamges to be loaded.

This requires javascript if javaascript is disabled then the lazyloading images won't load.



example:

a gif of html page scrolling down

Image credits:

Horse: https://www.freeimages.com/photo/horse-1393073

Butterfly: https://www.freeimages.com/photo/butterfly-1392408

Goat: https://www.freeimages.com/photo/my-beloved-mountains-2-1375135

Rope Knot: https://www.freeimages.com/photo/hunter-s-bend-1316926