The Story
I have this internal tool for some purpose. Now, this has a page where it displays like 50+ images grid in smaller sizes.
The page always load very slow and I hated it.
So We can solve this by properly generating smaller thumbnails of the images and/or lazy loading the images.
This isn't really isn't used by anyone else other than me. So I decided to skip the thumbnail part and add 2 lines of js to lazy load the hack out of these stupid images.
Then I stumbled upon something I completely forgot that existed.
loading="lazy"
<img src="..." loading="lazy" />
That's pretty much everything you need to make your images lazy load.
Now this is an HTML5 Feature and probably might not be supported by every browser out there.
It might not bring fancy animations and fade transitions onto the table
But IT WORKS!!
The previous webpage is atleast 3 times as fast.
Read more here: MDN
TL;DR
Use the loading
attribute in HTML
<img src="..." loading="lazy" />
Update
You definitely should not use it in anything important.
You need a polyfill to get it work on all browsers.
Read my story and see why I used it.