Performance: File-based routing
MEDIUM IMPACT
File-based routing impacts initial page load speed and navigation responsiveness by controlling how routes are resolved and components are loaded.
const routes = { '/': () => import('./routes/Home.svelte'), '/about': () => import('./routes/About.svelte'), '/contact': () => import('./routes/Contact.svelte') }; // Components loaded only when route is visited
import Home from './routes/Home.svelte'; import About from './routes/About.svelte'; import Contact from './routes/Contact.svelte'; // All routes imported and bundled together const routes = { '/': Home, '/about': About, '/contact': Contact };
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Eager loading all routes | Low (few nodes initially) | 1 reflow on load | High paint cost due to large bundle | [X] Bad |
| Lazy loading routes on demand | Low (nodes added per route) | 1 reflow per route load | Lower paint cost initially | [OK] Good |