Switch all navigable route components to React.lazy() and wrap <Routes> in <Suspense>. Dashboard/Login/Layout stay eager since they're the shell. Initial index bundle drops 246kB -> 34.67kB (gzip 10.5kB). Each route becomes its own 8-51kB chunk, loaded on demand. Nav hover/focus triggers prefetchRoute(path) which fires the same dynamic import() specifier the bundler dedups against React.lazy, so the chunk is warm by the time the user clicks. Avoids the Suspense flicker that would otherwise show on every first nav.
1.6 KiB
1.6 KiB