fix(perf): refactor HeroVideo to provide immediate Next.js optimized LCP image behind video

This commit is contained in:
2026-06-21 11:40:54 +02:00
parent d068d68d7a
commit 27fc34e186

View File

@@ -46,27 +46,29 @@ export function HeroVideo(props: HeroVideoProps) {
{/* Background color while video loads */} {/* Background color while video loads */}
<div className="absolute inset-0 z-0 bg-neutral-dark" /> <div className="absolute inset-0 z-0 bg-neutral-dark" />
{videoUrl ? ( {/* ALWAYS render the Next.js optimized Image as the LCP element */}
<video
key={`${pathname}-${videoUrl}`}
className="absolute inset-0 w-full h-full object-cover z-1 pointer-events-none filter contrast-125 saturate-110 brightness-90"
src={videoUrl}
autoPlay
muted
loop
playsInline
preload="auto"
/>
) : (
<Image <Image
key={`img-${pathname}-${posterSrc}`} key={`img-${pathname}-${posterSrc}`}
src={posterSrc} src={posterSrc}
alt={posterAlt} alt={posterAlt}
fill fill
className="object-cover z-1 pointer-events-none filter contrast-125 saturate-110 brightness-90" className="object-cover z-[1] pointer-events-none filter contrast-125 saturate-110 brightness-90"
sizes="100vw" sizes="100vw"
priority priority
/> />
{/* Render video on top if available, but don't force aggressive preload */}
{videoUrl && (
<video
key={`${pathname}-${videoUrl}`}
className="absolute inset-0 w-full h-full object-cover z-[2] pointer-events-none filter contrast-125 saturate-110 brightness-90"
src={videoUrl}
autoPlay
muted
loop
playsInline
preload="metadata"
/>
)} )}
{/* Cinematic Color Grading Overlay */} {/* Cinematic Color Grading Overlay */}