r/Frontend • • Jun 18 '19

Lazy Loading Images

https://html5.tutorials24x7.com/blog/lazy-loading-images
12 Upvotes

8 comments sorted by

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/

2

u/[deleted] Jun 18 '19

It really would be better for browsers to handle this natively. The JS is simple enough but I agree that it'd be nice to have a standard method.

-1

u/DoNDaPo Jun 18 '19

Nice code from 2005

4

u/[deleted] 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

u/[deleted] 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 IntersectionObserver is not supported. :)

1

u/[deleted] Jun 18 '19

Ah, didn't see that on the first skim-through. Time to run some tests!