Don't Debounce Lazy Loading: Benchmark Loaded Only 4 of 120 Images
Fast-scrolling users on pages that rely on scroll + debounce lazy loading see unfilled images until they stop scrolling, a silent failure in long lists, anchor jumps, and End-key jumps. Native loading=lazy is more aggressive than most handwritten IO and costs one line, so the benchmark gives a data-backed reason to switch or at least widen rootMargin to 1000px.
A systematic comparison of nine lazy loading approaches on 120 images (67KB each, local server, cache disabled) produced a clear winner and one catastrophic loser. Scroll + debounce 250ms, a pattern still common in tutorials, loaded only 4 of 120 images when the page scrolled to the bottom in one continuous motion. The median image-ready delay was 615ms, and the mechanism is the problem: every scroll event resets the timer, so the load check never runs until scrolling stops. When it finally does, only the last few images are in view. The same setup with scroll + requestAnimationFrame had a 14ms delay, a 44x difference.
Native loading=lazy preloads at roughly 1250px and got images ready 851ms earlier on average. Handwritten IntersectionObserver code with the widely taught rootMargin of 200px only managed 119ms of early readiness; matching native required rootMargin of 1000px, which reached 685ms early. The benchmark also debunked two myths: fetchpriority=low had zero effect on lazy-loaded images, and bare scroll listeners didn't cause jank (median frame time stayed at 17ms with zero long tasks) but were slower than IO. Lazy loading's real payoff is bandwidth: it cuts initial requests from 120 to 1-7, not frame rate.
Debounce is fundamentally mismatched with scroll events because it resets on every trigger, so any continuous scroll postpones the load check indefinitely. This is a mechanism flaw, not a tuning issue.
The browser's native lazy loading is more aggressive than what most handwritten IO tutorials recommend (200px rootMargin). Following common advice makes users wait half a second longer, so the 'handwritten is better' assumption doesn't hold for typical configurations.
The perception that bare scroll listeners cause jank is overstated at this scale; the real cost is latency in ready time, not frame drops. Performance profiling should separate these two concerns.
Lazy loading's primary win is network savings, not rendering performance. Optimizing for frame rate with a scroll listener misses the point.
The debounce setup is the real culprit behind only 4 of 120 images loading during fast scrolling; throttling at 250ms avoids the endless postponement. Native lazy loading's 1250px prefetch is not a universal constant—Chrome jumps to 2500px on 3G and below—so local fast-network benchmarks overstate how easily a handwritten IntersectionObserver can match native. A secondary suggestion is to report the loading completeness rate for round-trip scrolls as an extra metric.
Switching debounce to throttle brings it back to life—during scrolling it checks at least once every 250ms, so it never gets pushed back indefinitely. Also, Chrome's native lazy-load prefetch distance depends on network speed: 1250px on 4G, and directly 2500px on 3G and below. What a local server measures is the fast-network tier; if handwritten IO is meant to match native on weak networks, rootMargin needs to be dialed up further.
Professional.
You could also measure the loading completeness rate for round-trip scrolling.
That's also a metric.
I've pinned the version where only that image loads to 3.2. After upgrading to 4.0, one behavior changed—have any of you run into it?
Haven't encountered it.