How to lazy load images

How to lazy load images

Kevin Powell

5 лет назад

111,321 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@angepicard7968
@angepicard7968 - 17.12.2019 22:37

You should at least use ts-check with vscode to spot those errors earlier ! :p

Ответить
@victorwillhuber
@victorwillhuber - 13.01.2020 14:02

I have a question if you have time. I'm using <picture> to load .webp format when is supported and .jpg formato when is not (safari ¬¬)... how can I use this method for lazy load and still use <picture> tag. i'm doing that because of SEO... google is telling me to use "images of last generation format"

Ответить
@andreroxhage4003
@andreroxhage4003 - 24.01.2020 13:32

Great video! Thanks!

Ответить
@the.real.ipatch
@the.real.ipatch - 21.02.2020 00:51

is there is a project repo on your github for this video, i looked through your repositories but didn't see one for this particular video.

Ответить
@DJDeyon
@DJDeyon - 13.03.2020 18:29

He sound like Gus from Rooster Teeth

Ответить
@rashikkarmacharya8023
@rashikkarmacharya8023 - 24.03.2020 11:59

Nice man!!

Ответить
@rickyu1978
@rickyu1978 - 07.04.2020 19:35

Hi Kev, really like your intersection obs tutorials. As of Chrome 75, loading="lazy" became a thing.. how does that compare with lazy loading images using the intersection observer?

Ответить
@sarabb2056
@sarabb2056 - 17.04.2020 02:10

You provide really good instructions, thank you!

Ответить
@stratvids
@stratvids - 29.04.2020 22:55

if(!something) return; else { dostuff } ?? you should be doing if(something) { dostuff }

Ответить
@amadousow6598
@amadousow6598 - 09.05.2020 13:08

thx can you do it in angular ?

Ответить
@lindavanhoutum6223
@lindavanhoutum6223 - 13.05.2020 20:31

Is there a way to unload the images again? So to remove the src attribute and add the data-src again?

Ответить
@galalistationery9434
@galalistationery9434 - 17.05.2020 14:46

bro I want to create an eCommerce website , how to host my image cdn website should you use cdn image or no....?

Ответить
@guersomfalcon7544
@guersomfalcon7544 - 31.05.2020 01:36

In what situation would it be useful to load the images like this?

Ответить
@statusclinic
@statusclinic - 02.06.2020 14:50

nice

Ответить
@brian554xx
@brian554xx - 26.06.2020 19:29

I like to be alone.
You are one of very few exceptions. Having you around feels comfortable.

Ответить
@gearedcorp
@gearedcorp - 02.07.2020 23:30

I have been experimenting with the IntersectionObserver for a while because I would like to add lazyloading to my stores but I have been stumbling in one area which I can't figure out, that is rootMargins. I followed your tutorial exactly to see if I could reproduce your example on screen which I can largely except for the rootMargins.
The images load after coming fully into view on the screen (that is the threshold setting) but ignore the rootMargin value all together.
Can you or anyone else identify why that might be? Is it browser specific?

Ответить
@davidaragon7741
@davidaragon7741 - 04.07.2020 07:22

I've been following you for a while, first comment ever, this is absolutely awesome! More JS tutorials please!

Ответить
@greglumley8249
@greglumley8249 - 14.08.2020 17:52

Hey Kevin, thanks for putting these up. You teach really nicely.

Ответить
@BalachandranSumathiB
@BalachandranSumathiB - 22.08.2020 22:54

Thanks a lot!, I tried the code. It is fantastic. Can you do a custom gallery like fancybox. Need something lighter. Also can u tell how to do a masonry left to right gallery?

Ответить
@martinquintero1159
@martinquintero1159 - 05.09.2020 15:57

Hi Kevin! Would this work for embed videos aswell?

Ответить
@ibknl1986
@ibknl1986 - 28.10.2020 12:39

Your teaching is a blessing.

Ответить
@rashedobeidat2612
@rashedobeidat2612 - 20.11.2020 14:07

Tutorials are accumulated on top of each other. not a very good option if you are here to only learn how to lazy load html images.

Ответить
@phillaelony3035
@phillaelony3035 - 07.12.2020 04:30

Thank you so much for this amazing video!

Ответить
@XerosXIII
@XerosXIII - 14.12.2020 08:19

and here im wondering what happened to waypoints.js

Ответить
@ruslankh9004
@ruslankh9004 - 06.01.2021 02:01

Thanks a lot! Great video!

Ответить
@karamveersachdeva935
@karamveersachdeva935 - 25.01.2021 13:59

Awesome sir

Ответить
@rogerccaqp
@rogerccaqp - 02.03.2021 04:46

Hi.
Nice video. and good technique lazy loading images on Scrolling





if my images GET from a fetch request Api json and all images shows in viewport in same time?.
i want like a placeholder for each image until the image is fully loaded.

Ответить
@shgysk8zer0
@shgysk8zer0 - 21.04.2021 01:16

I'm working on a similar technique. The primary difference is that I'm adding images (any content, really) inside of a <template> and <noscript> and doing `tmp.replaceWith(tmp.content)` on intersection.

I think this is the absolute optimal technique on what's currently available, with the possible exception of native lazy loading.

Ответить
@pchound5962
@pchound5962 - 04.06.2021 18:38

You don't have the exact link to the codepen code, only your user page.

Ответить
@alighoneim8042
@alighoneim8042 - 13.07.2021 21:57

from where to copy the code

Ответить
@Mia_The_Panda-9YrOld
@Mia_The_Panda-9YrOld - 21.08.2021 05:06

thanks a lot

Ответить
@linchen5913
@linchen5913 - 27.08.2021 06:40

Thankfully, we don't have to do lazy loading this way... So troublesome. All we need to do is add "loading='lazy'" to the img tag we have, hooray!

Ответить
@jomoc6112
@jomoc6112 - 21.10.2021 12:24

@Kevin can i use this as it will load blur images first then loads the clear one on intersect

Ответить
@awaiskamran8448
@awaiskamran8448 - 21.10.2021 13:37

Thanks Kevin, this was really helpful

Ответить
@ifathere
@ifathere - 15.12.2021 19:03

absolutely cool intersection obeser

Ответить
@legostud
@legostud - 30.01.2022 05:37

There’s an easier approach now. Add the ‘loading’ attribute to the ‘img’ tag and set it equal to “lazy”

Ответить
@ColinPittendrigh
@ColinPittendrigh - 06.02.2022 18:59

Does lazy loading mean it is now OK to make long pages with many images? Or at least extend conventional wisdom about page length and image number best practices?

Ответить
@natobrittonfutbolfun4328
@natobrittonfutbolfun4328 - 16.02.2022 01:57

Thank You Kevin! Your enthusiasm is very contagious... I love the way you showed us in the CSS applying it at 300px and -500px. You are very articulate too and I appreciate this since I am a new learner of JS and CSS.

Ответить
@pratikmore3122
@pratikmore3122 - 16.02.2022 14:00

Awesome 👍

Ответить
@FaisalMalik-fu5vn
@FaisalMalik-fu5vn - 07.05.2022 07:36

Hey, Kevin great video! Can you please guide us on how to disable WordPress native lazy loading for the hero/featured image or largest contentful paint?

Ответить
@lucianchevvy97
@lucianchevvy97 - 14.06.2022 14:55

Great vid!

Ответить
@SahilRajput03
@SahilRajput03 - 05.07.2022 14:38

Please post the code here for this ??

Ответить
@el_tjonte3547
@el_tjonte3547 - 29.09.2022 12:22

You just knew what my site needed ...thank you✌

Ответить
@zonsubba3654
@zonsubba3654 - 13.11.2022 14:54

Awesome content. I really was needing this. Thanks Kevin.

Ответить
@tyoung3455
@tyoung3455 - 25.11.2022 18:39

This is the stupidest feature ever. It is horribly distracting to anyone searching on a webpage to have something flashing on the screen as you scroll.

Ответить
@xreev0x
@xreev0x - 18.09.2023 16:10

Creating IntersectionObserver options never works for me. The observer never triggers. But simply not including options it works.

Ответить