Performance: Sticky header and footer
MEDIUM IMPACT
Sticky headers and footers affect page rendering and scrolling performance by keeping elements fixed during scroll.
<header class="sticky top-0 bg-gray-800 h-16"></header> <footer class="sticky bottom-0 bg-gray-800 h-16"></footer>
<header class="fixed top-0 left-0 w-full h-16 bg-gray-800"></header> <footer class="fixed bottom-0 left-0 w-full h-16 bg-gray-800"></footer>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Fixed header/footer | Low (2 nodes) | Multiple on scroll | High due to repaint on scroll | [X] Bad |
| Sticky header/footer | Low (2 nodes) | Single on layout | Low repaint cost on scroll | [OK] Good |