superfly / edge

A set of useful libraries for Edge Apps. Run locally, write tests, and integrate it into your deployment process. Move fast and maybe don't break things? Because, gosh darnit, you're an adult.
https://fly.io
Apache License 2.0
143 stars 10 forks source link

Middleware: Lazy Loading Images #40

Open barnese3 opened 5 years ago

barnese3 commented 5 years ago

Middleware feature that will help improve page load time: Lazy Loading — delay the loading of images in long web pages. Images outside of the viewport will not be loaded until the user scrolls to them.

Replace src's with data-image-src tags. Use the IntersectionObserver API to observe when images enter the browsers viewport. When an image comes into view, switch back to src.

For background images, grab their url's and hide/store until image comes into view.

I can get started on this if we think it's a good feature to add.

i8ramin commented 5 years ago

relevant: https://www.xda-developers.com/google-chrome-image-lazy-loading-speed-up-page-loading-mobile/