Live data from Hacker News

Native lazy loading has landed in Chrome

dev.to

41–49 of 49 posts

Re: Native lazy loading has landed in Chrome

#41
This is a poorly thought feature.

You always want to have the image loaded before you actually use it. You don't want to wait until you actually use the image. For instance in a carousel, you'll want to load the next and previous image, not just the current displayed one.

I'd much rather have a "loading order" than lazy loading. Sure, I don't want to load first the big images that I'll want to display later, but I definitely don't want them to appear while I scroll down...

Re: Native lazy loading has landed in Chrome

#42

For anyone hearing about loading=“lazy” for the first time from this article , I’ll reiterate the main idea because the article doesn’t go into much depth about the motivation. The main idea is that some pages use a lot of cellular data to load images that are further down the page, out of the viewport. If the user glances at the page and decides it’s not relevant and exits, then those offscreen images were just a wa…

The demo on the page clearly shows a delay between the start of the load and the actual display of the image. So "soon to be in the viewport" should be quite sooner.

Re: Native lazy loading has landed in Chrome

#44
post #41

This is a poorly thought feature. You always want to have the image loaded before you actually use it. You don't want to wait until you actually use the image. For instance in a carousel, you'll want to load the next and previous image, not just the current displayed one. I'd much rather have a "loading order" than lazy loading. Sure, I don't want to load first the big images that I'll want to display later, but I de…

This is covered in the part about the “calculated distance” where they describe the logic used to load the images in the current implementation: it loads before use but waits until the images are near the viewport.

There's an FAQ about carousels, too:

https://web.dev/native-lazy-loading#how-does-the-loading-att...

> How does the loading attribute work with images that are in the viewport but not immediately visible (for example, behind a carousel)? > > Only images that are below the device viewport by the calculated distance load lazily. All images above the viewport, regardless of whether they're immediately visible, load normally.

Re: Native lazy loading has landed in Chrome

#45
post #7

I'm happy to see this. So many websites with lazy loading never implemented a fallback for noscript. And most of the popular libraries didn't account for this accessibility.

just curious -- in what situation would your average user not have javascript turned on?

It's becoming more common as people use aggressive blockers but the main reason to care about it is that JavaScript breaks fairly regularly. On LTE, I see pages where a simple HTML display would work but a JavaScript loader failed on first load generally a couple of times a day.

Re: Native lazy loading has landed in Chrome

#46

Earlier quoted context omitted.

Maybe it was just done out of habit. A bool can be expected today. But why about 10 years from now? Defensive programming isn't a bad thing. Making assumptions is why we had the Y2K mess.

That's an unreasonable, excessive use of defensive programming. We're not talking about an unstable API here, we're talking about an operator. It would be just as unreasonable to "defend" your code against `1 + 1` suddenly returning a boolean rather than a number.

You already know that ìn` will return either `true` or `false`. Why use `==` which will convert data instead of `===` which will test for a boolean directly?

Ignore the symbols and use the words. Which makes more sense to you?

"[My test] strictly equals true." or "[My test] loosely equals true."

Re: Native lazy loading has landed in Chrome

#47

Earlier quoted context omitted.

Maybe it was just done out of habit. A bool can be expected today. But why about 10 years from now? Defensive programming isn't a bad thing. Making assumptions is why we had the Y2K mess.

That's an unreasonable, excessive use of defensive programming. We're not talking about an unstable API here, we're talking about an operator. It would be just as unreasonable to "defend" your code against `1 + 1` suddenly returning a boolean rather than a number.

This looks future proof to me: `if (JSON.stringify("something" in foo).match(/t/) != null) { … }`

Re: Native lazy loading has landed in Chrome

#48
I may be the odd one out here, but I hate lazy loading. I get why it's a big thing on cellular connections, but I do most of my browsing on WIFI. With lazy loading I'll frequently be reading an article, reach an image that hasn't loaded in yet, and have to wait for it, even though I've been reading for several minutes. Sometimes I also have to refind my place as the whole darn page reflows.

I wish there was a middle ground... detect I'm on WIFI and go ahead and load in the lazy stuff after the above the fold stuff.

Re: Native lazy loading has landed in Chrome

#49
post #45

Earlier quoted context omitted.

just curious -- in what situation would your average user not have javascript turned on?

It's becoming more common as people use aggressive blockers but the main reason to care about it is that JavaScript breaks fairly regularly. On LTE, I see pages where a simple HTML display would work but a JavaScript loader failed on first load generally a couple of times a day.

With uMatrix I'm often without the necessary script to load basic static content. I love JavaScript and PWAs, but many sites aren't an application so I don't want extra scripts running who knows what.
Post reply on HN