Performance: Metadata in layouts
MEDIUM IMPACT
This affects the page load speed by controlling how metadata is loaded and rendered, impacting the Largest Contentful Paint (LCP).
export const metadata = { title: 'My Site', description: 'Default description' }; export default function Layout({ children }) { return ( <html> <body>{children}</body> </html> ); }
export default function Layout({ children }) { return ( <html> <head> <title>My Site</title> <meta name="description" content="Default description" /> </head> <body>{children}</body> </html> ); }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Hardcoded metadata inside layout render | Multiple DOM updates during hydration | Triggers 1 reflow on metadata injection | Medium paint cost due to delayed head update | [X] Bad |
| Static metadata export in layout file | No extra DOM updates for metadata | No reflows triggered by metadata | Minimal paint cost, metadata preloaded | [OK] Good |