Performance: Layout vs template difference
MEDIUM IMPACT
This concept affects how quickly the main page content loads and how efficiently the browser updates the UI when navigating between pages.
export default function Layout({ children }) { return ( <> <header>Site Header</header> <main>{children}</main> <footer>Site Footer</footer> </> ) } // Pages use Layout to wrap content, so header/footer render once.
export default function Page() { return ( <> <header>Site Header</header> <main>Page content</main> <footer>Site Footer</footer> </> ) }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Template with repeated header/footer | High (full page nodes recreated) | Multiple reflows per navigation | High paint cost due to full repaint | [X] Bad |
| Layout with shared header/footer | Low (shared nodes reused) | Single reflow for content update | Lower paint cost focused on content | [OK] Good |