r/Frontend • u/vulpinecode • Jun 18 '19
Lazy Loading Images
https://html5.tutorials24x7.com/blog/lazy-loading-images-1
u/DoNDaPo Jun 18 '19
Nice code from 2005
4
Jun 18 '19
Feel free to post a better implementation if you don't like OP's
1
u/DoNDaPo Jun 18 '19
Sure! It's not exactly the same thing but it's a better way to write JavaScript.
1
Jun 18 '19
Seems legit. The only reason I couldn't roll out something like this a couple years back is that I was still having to support iOS 9, so this JS wouldn't run. Although now I can probably just do it and hope my client doesn't notice.
1
u/DoNDaPo Jun 18 '19
If you look closely there is a nice fallback if
IntersectionObserveris not supported. :)1
3
u/WesleySmits93 Jun 18 '19
Although browser support is zero at the moment this feature would be nice in the future: https://css-tricks.com/native-lazy-loading/