Intersection Observer API
Definition
The Intersection Observer API reports when an element enters or leaves the viewport, or another element, asynchronously and off the main thread. A callback receives only the entries that changed. It replaces scroll handlers that measure geometry on every frame, and it's the browser's answer to work that should happen because of where something is.
Documented at MDN, the Intersection Observer API.
How We've Used It
Almost everything we defer is deferred on this. Widgets mount near the viewport instead of on load, including reviews, shoppable video and carousel libraries, so a page carrying several vendors mounts each one only when its section comes into view. Reveal animations use it too, and there the interesting decision is what to observe: one lead element per grid row rather than every card, so a row appears as a unit and the callback count drops by the column count. Anything bound this way has to survive a re-render, so observers are disconnected and rebuilt when a filtered grid replaces its own contents.
Builds Using It
- Theme-wide section reveal that replaces Dawn's per-element scroll animations — LUS Brands
- Homepage hero carousel v2 - video and split-image slides with per-slide typography control — Nudestix
- Kids featured collection: a custom element that builds its Swiper on approach and wraps the theme's own product cards — LUS Brands
- Layout shell rewritten as a load-order contract: origin hints, two stylesheet tiers and an interaction-gated session recorder — Nudestix
- Deferred LyveCom shoppable-video mounting on the product page — LUS Brands
- Mega-menu product rail (v2): a library-free slider in a theme asset, constructed per panel when the panel is seen — Nudestix
One further gated build uses it; its page follows.
Related Entities
- Deferred media — the heaviest thing it defers.
- Deferred CSS loading — the same budget, applied to stylesheets.
- Custom elements — where the observers are created and torn down.
- Liquid pagination — the page ladder scroll loading sits on.