Performance: Why layouts avoid redundant rendering
HIGH IMPACT
This concept affects page load speed and interaction responsiveness by reducing unnecessary re-rendering of shared UI parts.
function Layout({ children }) { return ( <> <header>Site Header</header> <main>{children}</main> <footer>Site Footer</footer> </> ) } export default function Page() { return <Layout>Page Content</Layout> }
export default function Page() { return ( <> <header>Site Header</header> <main>Page Content</main> <footer>Site Footer</footer> </> ) }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No layout, repeated UI in pages | High (header/footer recreated each page) | Multiple reflows per navigation | High paint cost due to full UI repaint | [X] Bad |
| Shared layout wrapping pages | Low (header/footer mounted once) | Single reflow on initial load | Lower paint cost, only main content repainted | [OK] Good |