filmov
tv
Native Lazy Loading + A Fallback Solution ..in 60 seconds
![preview_player](https://i.ytimg.com/vi/6mTKlOGBYfM/maxresdefault.jpg)
Показать описание
(Codepen code below) Chrome just released native lazy loading, so here's an insanely succinct video that will show you how to get up and running with a fallback solution using 'lazysizes'.
Tutorial dialogue:
"First, we need to enable lazy loading in the chrome flags because this is, well, sort of new..
Intially, we'll load these images without lazy loading, just to show you what the network tab looks like -- you're pointlessly loading all of this content when a user might not scroll down! (WASTE OF BANDWIDTH)
We're going to change the src attribute to a custom attribute, and add loading="lazy" to make this work..
Next, we write a bit of JavaScript to determine if the browser supports native lazy loading. Yay, ours does!
If it does support it, we iterate through our images and add the src attribute.
If there's no support, we can dynamically include a javascript src to a third party lazy loading library like lazysizes as a fallback!
Check it out, it's only loading the first few images. As the user scrolls, it works, yay!
For the fallback, add the lazyload class. Try it out in a non supporting browser like firefox and watch it work!"
This tutorial was based on the great content about native lazy loading found here:
What's up with the 60 second format? I stumbled across another channel in a different niche that provides 60 second tutorials and thought I'd give it a shot. Thoughts?
Sign up to my UI design course coming out very shortly!
- - - - - - - - - - - - - - - - - - - - - -
Subscribe for NEW VIDEOS!
^-Chat with me and others
- - - - - - - - - - - - - - - - - - - - - -
Come to my discord server or add me on social media and say Hi!
Tutorial dialogue:
"First, we need to enable lazy loading in the chrome flags because this is, well, sort of new..
Intially, we'll load these images without lazy loading, just to show you what the network tab looks like -- you're pointlessly loading all of this content when a user might not scroll down! (WASTE OF BANDWIDTH)
We're going to change the src attribute to a custom attribute, and add loading="lazy" to make this work..
Next, we write a bit of JavaScript to determine if the browser supports native lazy loading. Yay, ours does!
If it does support it, we iterate through our images and add the src attribute.
If there's no support, we can dynamically include a javascript src to a third party lazy loading library like lazysizes as a fallback!
Check it out, it's only loading the first few images. As the user scrolls, it works, yay!
For the fallback, add the lazyload class. Try it out in a non supporting browser like firefox and watch it work!"
This tutorial was based on the great content about native lazy loading found here:
What's up with the 60 second format? I stumbled across another channel in a different niche that provides 60 second tutorials and thought I'd give it a shot. Thoughts?
Sign up to my UI design course coming out very shortly!
- - - - - - - - - - - - - - - - - - - - - -
Subscribe for NEW VIDEOS!
^-Chat with me and others
- - - - - - - - - - - - - - - - - - - - - -
Come to my discord server or add me on social media and say Hi!
Комментарии