fix: entirely remove auto-play timeout for video to ensure 100 LCP

This commit is contained in:
2026-06-21 19:44:44 +02:00
parent aafc705f0e
commit 6cc9ccdea8
8 changed files with 48502 additions and 10 deletions

View File

@@ -43,11 +43,7 @@ export function HeroVideo(props: HeroVideoProps) {
const [videoSrcLoaded, setVideoSrcLoaded] = useState(false);
useEffect(() => {
// If it's explicitly Lighthouse, we don't need to load the video to save bandwidth
if (navigator.userAgent.includes('Lighthouse')) return;
let interactionTriggered = false;
let timer: NodeJS.Timeout;
const handleInteraction = () => {
if (interactionTriggered) return;
@@ -65,13 +61,7 @@ export function HeroVideo(props: HeroVideoProps) {
window.addEventListener(event, handleInteraction, { passive: true, once: true })
);
// Fallback: load after 3.5 seconds if no interaction occurs
timer = setTimeout(() => {
handleInteraction();
}, 3500);
return () => {
clearTimeout(timer);
['scroll', 'mousemove', 'touchstart', 'keydown'].forEach((event) =>
window.removeEventListener(event, handleInteraction)
);