I'm building a website for a gallery owner that has a lot of images per webpage. Therefore I want to lazy load the images on the webpage, making the initial load less heavy. However, I would like to implement this in a "progressive enhancement" way.
I've found a lot of lazy loading methods but they all require fiddling with the html code
in such a way that the webpage would be useless with javascript turned off. (eg. the src
attribute of the img
tags remains unset until the images is lazy loaded).
To implement a lazy loading method progressivly I think one would need the following:
- prevent the browser from fetching the images, even though thers are on the page, but only do this when javascript is on (so on non-javascript browsers, the images still load as normal). This should be done without altering the html.
- save the
src
attribute in adata-src
attribute - sequentually load the images when scrolling down
Of these three steps the first one seems the hardest one. Even this stackoverflow discussion did not provide an answer that doesn't ruin progressive enhancement.
Has anyone got any ideas?