Performance: Defining routes
MEDIUM IMPACT
This affects the initial page load speed and navigation responsiveness by controlling how components are loaded and rendered.
const routes = [ { path: '/', component: () => import('./views/Home.vue') }, { path: '/about', component: () => import('./views/About.vue') } ];
import Home from './views/Home.vue'; import About from './views/About.vue'; const routes = [ { path: '/', component: Home }, { path: '/about', component: About } ];
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Eager route imports | Low | Low | High (due to large JS bundle) | [X] Bad |
| Lazy-loaded routes | Low | Low | Low (smaller JS bundle) | [OK] Good |