Overview
Scroll listeners fire dozens of times per frame and are easy to get wrong. Intersection Observer hands you the same information passively, batched, and at no cost when the element is off-screen.
Highlights
- One observer can watch many elements — instantiate it once at module scope
- Use rootMargin to trigger work before an element actually enters the viewport
- Unobserve elements after they fire if the work is one-shot, like reveal animations
Comments