All checks were successful
Gitea CI / test-build (push) Successful in 11m36s
- Remove framer-motion from Hero.tsx and HeaderClient.tsx, replace with CSS animations/transitions - Replace lucide-react icons (Menu, X, Mail) with inline SVGs in HeaderClient.tsx - Lazy-load About, Projects, Contact, Footer via dynamic() imports in ClientWrappers.tsx - Defer ShaderGradient/BackgroundBlobs loading via requestIdleCallback in ClientProviders.tsx - Remove AnimatePresence page wrapper that caused full re-renders - Enable experimental.optimizeCss (critters) for critical CSS inlining - Add fadeIn keyframe to Tailwind config for CSS-based animations Homepage JS reduced from 563KB to 438KB (-125KB). Eliminates ~39s main thread work from WebGL init and layout thrashing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
73 lines
1.9 KiB
TypeScript
73 lines
1.9 KiB
TypeScript
"use client";
|
|
|
|
import React, { useEffect, useState } from "react";
|
|
import { usePathname } from "next/navigation";
|
|
import dynamic from "next/dynamic";
|
|
import { ToastProvider } from "@/components/Toast";
|
|
import ErrorBoundary from "@/components/ErrorBoundary";
|
|
import { ConsentProvider } from "./ConsentProvider";
|
|
import { ThemeProvider } from "./ThemeProvider";
|
|
|
|
const BackgroundBlobs = dynamic(() => import("@/components/BackgroundBlobs").catch(() => ({ default: () => null })), {
|
|
ssr: false,
|
|
loading: () => null,
|
|
});
|
|
|
|
const ShaderGradientBackground = dynamic(
|
|
() => import("./ShaderGradientBackground").catch(() => ({ default: () => null })),
|
|
{ ssr: false, loading: () => null }
|
|
);
|
|
|
|
export default function ClientProviders({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
const [mounted, setMounted] = useState(false);
|
|
const pathname = usePathname();
|
|
|
|
useEffect(() => {
|
|
setMounted(true);
|
|
}, [pathname]);
|
|
|
|
return (
|
|
<ErrorBoundary>
|
|
<ErrorBoundary>
|
|
<ConsentProvider>
|
|
<ThemeProvider attribute="class" defaultTheme="light" enableSystem={false}>
|
|
<GatedProviders mounted={mounted}>
|
|
{children}
|
|
</GatedProviders>
|
|
</ThemeProvider>
|
|
</ConsentProvider>
|
|
</ErrorBoundary>
|
|
</ErrorBoundary>
|
|
);
|
|
}
|
|
|
|
function GatedProviders({
|
|
children,
|
|
mounted,
|
|
}: {
|
|
children: React.ReactNode;
|
|
mounted: boolean;
|
|
}) {
|
|
// Defer heavy Three.js/WebGL background until after LCP
|
|
const [deferredReady, setDeferredReady] = useState(false);
|
|
useEffect(() => {
|
|
if (!mounted) return;
|
|
const id = requestIdleCallback(() => setDeferredReady(true), { timeout: 5000 });
|
|
return () => cancelIdleCallback(id);
|
|
}, [mounted]);
|
|
|
|
return (
|
|
<ErrorBoundary>
|
|
<ToastProvider>
|
|
{deferredReady && <BackgroundBlobs />}
|
|
{deferredReady && <ShaderGradientBackground />}
|
|
<div className="relative z-10">{children}</div>
|
|
</ToastProvider>
|
|
</ErrorBoundary>
|
|
);
|
|
}
|