Skip to main content

Practice ยท 2 of 2

Lazy-Load on Visibility

Model IntersectionObserver. Write createLazyLoader() returning { observe, intersect } โ€” observe(el, onLoad) registers an element with a pending state; intersect(el) simulates it entering the viewport: the FIRST call marks it loaded, fires its onLoad(el) exactly once, and returns true; subsequent intersects return false and do nothing. Unknown elements return false.

Difficulty: intermediate

Back to lesson: Practice: Timers & Observers โ€” Practice