Performance: App directory (App Router)
MEDIUM IMPACT
This affects the page load speed and rendering performance by how Next.js organizes and loads routes and components.
app/
page.js
about/page.js
contact/page.js
layout.js
components/
Header.js
Footer.js
// Components and routes are loaded per route automaticallypages/
index.js
about.js
contact.js
components/
Header.js
Footer.js
// All components imported globally in _app.js| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Pages directory with global imports | High (all components loaded) | Multiple reflows due to large JS | High paint cost from large DOM | [X] Bad |
| App directory with route-based code splitting | Low (only route components) | Single reflow per route | Lower paint cost with smaller DOM | [OK] Good |