This version is old school.
Please find jQuery plugins on npm.
BttrLazyLoading
BttrLazyLoading is a jQuery plugin that allows your web application to only load images within the viewport. It also multi serves responsive images for 4 differents screen sizes.