Intersection Observer for Lazy Loading
An efficient, asynchronous browser API for detecting when an element enters or exits the viewport, commonly used for lazy loading and infinite scroll.
IntersectionObserver is a browser API purpose-built for efficiently detecting when a target element becomes visible within (or scrolls out of) the viewport or another specified ancestor element, without the severe performance cost of the older technique of manually calculating element positions on every scroll event, which fires extremely frequently and forces expensive synchronous layout reads if done naively. It's a strong, practical interview topic since it directly relates to real performance work like lazy-loading images and infinite scroll.
IntersectionObserver is like a lifeguard using peripheral vision to notice the instant someone crosses into the deep end (a threshold), rather than manually re-measuring everyone's distance from the deep-end line every single second (polling on scroll) — the lifeguard is only actively alerted exactly when it actually matters.