diff --git a/src/App.tsx b/src/App.tsx index 334c972..f7ef41a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,17 +1,19 @@ import './App.css' +import { lazy, Suspense } from 'react' import { BrowserRouter, Routes, Route } from 'react-router' import { ThemeProvider } from '@/hooks/useTheme' import { Layout } from '@/components/layout/Layout' import { LanguageProvider } from '@/hooks/useLanguage' -import { - HomePage, - AboutPage, - ExperiencePage, - ProjectsListPage, - ProjectDetailPage, - PhilosophyPage, - ContactPage, -} from '@/pages' +import { HomePage } from '@/pages/HomePage' + +// HomePage stays eager: it is the landing route and owns the LCP, so its code must +// already be in the entry chunk. The other six split out and load on navigation. +const AboutPage = lazy(() => import('@/pages/AboutPage').then((m) => ({ default: m.AboutPage }))) +const ExperiencePage = lazy(() => import('@/pages/ExperiencePage').then((m) => ({ default: m.ExperiencePage }))) +const ProjectsListPage = lazy(() => import('@/pages/ProjectsListPage').then((m) => ({ default: m.ProjectsListPage }))) +const ProjectDetailPage = lazy(() => import('@/pages/ProjectDetailPage').then((m) => ({ default: m.ProjectDetailPage }))) +const PhilosophyPage = lazy(() => import('@/pages/PhilosophyPage').then((m) => ({ default: m.PhilosophyPage }))) +const ContactPage = lazy(() => import('@/pages/ContactPage').then((m) => ({ default: m.ContactPage }))) function App() { return ( @@ -19,18 +21,22 @@ function App() { - - } /> - } /> - } /> - } /> - } /> - } /> - } /> - - - - + {/* A null fallback keeps the shell (nav, footer) painted without reserving a + box that would shift the page when the route chunk lands. */} + + + } /> + } /> + } /> + } /> + } /> + } /> + } /> + + + + + ) } diff --git a/src/components/layout/Navigation.tsx b/src/components/layout/Navigation.tsx index 4f60483..d72d68d 100644 --- a/src/components/layout/Navigation.tsx +++ b/src/components/layout/Navigation.tsx @@ -57,7 +57,7 @@ export function Navigation() { return ( <> -