Skip to content

Commit 21cf0c5

Browse files
committed
Critical Bug Fix + Aggressive Performance Optimization
1 parent 3fd3abe commit 21cf0c5

2 files changed

Lines changed: 28 additions & 11 deletions

File tree

frontend/app/page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ Note: Built for AI Cybersecurity Research Portfolio.
1414
import Link from "next/link";
1515
import { ArrowRight, Terminal } from "lucide-react";
1616
import dynamic from "next/dynamic";
17-
import Spotlight from "@/components/ui/Spotlight";
1817
import TextScramble from "@/components/landing/TextScramble";
19-
import CursorSpotlight from "@/components/ui/CursorSpotlight";
2018
import BreathingText from "@/components/landing/BreathingText";
2119
import SystemStatusBadge from "@/components/ui/SystemStatusBadge";
22-
import HeroBackground from "@/components/landing/HeroBackground";
2320
import BackToTop from "@/components/ui/BackToTop";
2421

22+
// Lazy load heavy visual components to optimize initial performance
23+
const Spotlight = dynamic(() => import("@/components/ui/Spotlight"), { ssr: false });
24+
const CursorSpotlight = dynamic(() => import("@/components/ui/CursorSpotlight"), { ssr: false });
25+
const HeroBackground = dynamic(() => import("@/components/landing/HeroBackground"), { ssr: false });
2526
const PipelineVis = dynamic(() => import("@/components/landing/PipelineVis"), { ssr: false });
2627
const BentoGrid = dynamic(() => import("@/components/landing/BentoGrid"), { ssr: false });
2728

frontend/components/landing/HeroBackground.tsx

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Note: Renders Spline scene as hero section background overlay.
1010

1111
"use client";
1212

13-
import { useState } from 'react';
13+
import { useState, useEffect } from 'react';
1414
import dynamic from 'next/dynamic';
1515

1616
const Spline = dynamic(() => import('@splinetool/react-spline'), {
@@ -22,13 +22,29 @@ export default function HeroBackground() {
2222
const [isLoaded, setIsLoaded] = useState(false);
2323
const [shouldLoad, setShouldLoad] = useState(false);
2424

25-
// Defer loading of the heavy 3D scene to prioritize initial page interactivity
26-
useState(() => {
27-
const timer = setTimeout(() => {
28-
setShouldLoad(true);
29-
}, 2500);
30-
return () => clearTimeout(timer);
31-
});
25+
// Defer loading of the heavy 3D scene to completely avoid blocking initial performance metrics
26+
useEffect(() => {
27+
let timer: NodeJS.Timeout;
28+
29+
const startLoading = () => {
30+
// Wait 10 seconds after page is fully loaded before loading the 3D scene
31+
timer = setTimeout(() => {
32+
setShouldLoad(true);
33+
}, 10000);
34+
};
35+
36+
// Wait for the page to be fully loaded (all resources downloaded)
37+
if (document.readyState === 'complete') {
38+
startLoading();
39+
} else {
40+
window.addEventListener('load', startLoading);
41+
}
42+
43+
return () => {
44+
clearTimeout(timer);
45+
window.removeEventListener('load', startLoading);
46+
};
47+
}, []);
3248

3349
return (
3450
<div className="absolute inset-0 z-0 flex items-center justify-center">

0 commit comments

Comments
 (0)