How I built a scroll-driven video hero that still scores 100
Originally published on hadimoussawi.com . The hero on my site is a ten second film. Your scroll is its timeline: scroll down and the camera descends, scroll back and it climbs. It streams while it downloads, it never loads at all on phones, and the page still scores 100 for performance in Lighthouse. Here is how it works, and the four traps that cost me the most time. The idea A video that plays…
The hero section on the site features a ten-second video that scrolls along with the viewer. The video plays based on the scroll position rather than autoplaying. The video length equals the height of seven screens and is divided into five caption bands that fade in and out as the viewer scrolls. The scroll engine controls both the video and caption bands at a rate of sixty times per second without affecting React state.
Easing is time-based, not frame-based, ensuring consistent performance across devices. The video plays while downloading, reducing loading time for users, especially on mobile devices. The video uses fragmented MP4 encoding and Media Source to stream data directly to the video, allowing it to catch up to the scroll position as more data arrives.
The website also implements CSS gates to adapt the video experience for different devices and user preferences, optimizing performance and Core Web Vitals.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.