Help Interpreting Waterfall Results - Long Task

Hello Fellow Website Optimizers!

So I’ve been optimizing my website and think I have it pretty good. It gets a perfect rating on google pagespeed insights (lighthouse), gtmetrix.com and webpagetest.org. My only main weakness is TTFB as I’m currently self-hosting my site from home on a Synology NAS (protecting my origin IP with CloudFlare). I’ll fix my TTFB soon when I move the hosting.

However, my webpagetest.org results show a long ~1.2 second delay between first contentful paint and “fully loaded”.

I’m using the super popular “lazysizes” JS library to lazy load images on the site. The last 2 requests you see are lazy loaded images. However why such a long delay? It seems the browser main thread is mostly idle. Bandwidth is 0. Cpu utilization low-ish.

What does the long green bar on the bottom right of this waterfall mean?

Ok, while waiting for my post to be moderated, I actually solved my problem (or at least understand it).

The lazysizes JS deferred image loader has a weird “feature” where it insert a +1 second delay if your page onload event is faster than 1 second.

Excerpt from lazysizes source code:

[code]var onload = function() {
if (isCompleted) {
return;
}
if (Date.now() - started < 999) {
setTimeout(onload, 999);
return;
}

isCompleted = true;

lazySizesCfg.loadMode = 3;

throttledCheckElements();

addEventListener('scroll', altLoadmodeScrollListner, true);

};[/code]