diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx index 48f588632..6e6f93d57 100644 --- a/app/[locale]/layout.tsx +++ b/app/[locale]/layout.tsx @@ -21,7 +21,7 @@ import { DynamicInitialLoader as InitialLoader } from '@/components/providers/Dy import { DynamicMobileBottomNav as MobileBottomNav } from '@/components/layout/DynamicMobileBottomNav'; import { DynamicCorporateBackground as CorporateBackground } from '@/components/decorations/DynamicCorporateBackground'; -import { DynamicPageTransitionShutter as PageTransitionShutter } from '@/components/providers/DynamicPageTransitionShutter'; +const corporateBackground = null; // Removed to prevent line shifting const inter = Inter({ subsets: ['latin'], @@ -192,7 +192,7 @@ export default async function Layout(props: { - + {/* PageTransitionShutter loaded dynamically in TransitionProvider */}
diff --git a/app/[locale]/page.tsx b/app/[locale]/page.tsx index 1ca49bad4..64c0d39f5 100644 --- a/app/[locale]/page.tsx +++ b/app/[locale]/page.tsx @@ -133,7 +133,12 @@ export default async function Home(props: { params: Promise<{ locale: string }> setRequestLocale(locale); preload('/germany-map.svg', { as: 'image', fetchPriority: 'high' }); - preload('/assets/videos/web/hero-kabelpflug-poster.webp', { as: 'image', fetchPriority: 'high' }); + preload('/assets/videos/web/hero-kabelpflug-poster.webp', { + as: 'image', + fetchPriority: 'high', + imageSrcSet: '/assets/videos/web/hero-kabelpflug-poster-mobile.webp 800w, /assets/videos/web/hero-kabelpflug-poster.webp 1920w', + imageSizes: '(max-width: 768px) 800px, 1920px' + }); const mdx = await getMdxContent(locale, 'home'); const allReferences = await getAllReferences(locale); diff --git a/components/blocks/HeroVideo.tsx b/components/blocks/HeroVideo.tsx index 992ca31d7..b918c17c5 100644 --- a/components/blocks/HeroVideo.tsx +++ b/components/blocks/HeroVideo.tsx @@ -80,10 +80,11 @@ export function HeroVideo(props: HeroVideoProps) { {/* Background color while video loads */}
- {/* ALWAYS render a native img as the LCP element to avoid Render Delay */} {posterAlt} import('@/lib/framer-features').then(res => res.default); +// Defer loading the shutter to eliminate AnimatePresence from the initial bundle +const DynamicPageTransitionShutter = dynamic( + () => import('./PageTransitionShutter').then(mod => mod.PageTransitionShutter), + { ssr: false } +); + interface TransitionContextType { isTransitioning: boolean; transitionMessage: string | null; @@ -17,8 +24,18 @@ const TransitionContext = createContext(undef export function TransitionProvider({ children }: { children: ReactNode }) { const [isTransitioning, setIsTransitioning] = useState(false); const [transitionMessage, setTransitionMessage] = useState(null); + const [hasMountedShutter, setHasMountedShutter] = useState(false); const router = useRouter(); + // Load the heavy shutter chunk in the background when the main thread is idle + useEffect(() => { + if (typeof window !== 'undefined' && 'requestIdleCallback' in window) { + window.requestIdleCallback(() => setHasMountedShutter(true)); + } else { + setTimeout(() => setHasMountedShutter(true), 2000); + } + }, []); + // We use a ref to track transition state without triggering the route change effect when it turns true const isTransitioningRef = React.useRef(isTransitioning); useEffect(() => { @@ -44,6 +61,7 @@ export function TransitionProvider({ children }: { children: ReactNode }) { setTransitionMessage(message); setIsTransitioning(true); + setHasMountedShutter(true); // Die Animation des Shutters abwarten (ca. 700ms), dann pushen setTimeout(() => { @@ -72,6 +90,7 @@ export function TransitionProvider({ children }: { children: ReactNode }) { /> + {hasMountedShutter && } {children} diff --git a/public/assets/videos/web/hero-kabelpflug-poster-mobile.webp b/public/assets/videos/web/hero-kabelpflug-poster-mobile.webp new file mode 100644 index 000000000..9fcd03734 Binary files /dev/null and b/public/assets/videos/web/hero-kabelpflug-poster-mobile.webp differ diff --git a/public/assets/videos/web/hero-kabelpflug-poster.webp b/public/assets/videos/web/hero-kabelpflug-poster.webp index 3249b60c0..98456f7b7 100644 Binary files a/public/assets/videos/web/hero-kabelpflug-poster.webp and b/public/assets/videos/web/hero-kabelpflug-poster.webp differ