søren peter mørch

Conversation

Recent posts in reply to #cbq7yna

movq (www.uninformativ.de)

I complain about this a lot:

https://movq.de/v/e7cb49eefb/hiccupfx

But to be honest, my blog did the same thing – to some degree.

This is fixed now. The trick is to add width and height to all <img> tags. That way, modern browsers know how much space to reserve for the image. Without this, they just reserve zero space, so when the image finally loads, you get jumpy layout.

This effect is even worse when you use <img loading="lazy"> – which I can finally use, now that the jumpy layout has been fixed. 🥳

Read replies 5 months ago
lyse (lyse.isobeef.org)

@movq Good idea, I should probably do the same for my photo galleries.

In reply to: #cbq7yna 5 months ago
movq (www.uninformativ.de)

@lyse I noticed that loading="lazy" might not be so great after all.

This is without lazy loading:

https://movq.de/v/1ea351add4/s.png

The total page load time is around 400-500 ms. Okay.

Now this is with lazy loading:

https://movq.de/v/9708e1afff/s.png

It finished much quicker, after about 250 ms. Sounds good.

But notice this gap right here?

https://movq.de/v/96645a7a75/s.png

This wasn’t there before. With lazy loading, it now takes something like 80-100 ms until the browser even starts loading images. This is Chromium, but Firefox shows a similar gap.

The net result is that there is a very noticeable delay/flicker when you open a page, because it takes so long until the images have loaded. Yes, the layout doesn’t shift around, but that has nothing to do with lazy loading.

How odd. 🤔

In reply to: #cbq7yna 4 months ago
lyse (lyse.isobeef.org)

@movq Oooph! Web development is tidious.

I also include width and height from now on in my galleries.

In reply to: #cbq7yna 4 months ago
movq (www.uninformativ.de)

Ah, with lazy loading, browsers only start loading images when the load event occurs. And that takes time. Hm. Not a fan, I might revert this. 🤔

In reply to: #cbq7yna 4 months ago
movq (www.uninformativ.de)

tl;dr: Lazy loading is much better on slow internet lines but shittier on fast ones. 🫠

In reply to: #cbq7yna 4 months ago
movq (www.uninformativ.de)

Compromise: Don’t lazy-load the first ~7 images or so, i.e. the ones that are immediately in view.

In reply to: #cbq7yna 4 months ago
Reply via email