Skip to content

A pure javascript way to lazy load images without a server.

License

Notifications You must be signed in to change notification settings

9D-Tony/ImgLazyLoadingJavascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A pure javascript way to lazy load images without a server.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published