Performance: Scroll behavior control
MEDIUM IMPACT
Controls how the page scrolls and affects user interaction smoothness and visual stability during navigation.
window.scrollTo({ top: 0, behavior: 'smooth' });
window.scrollTo({ top: 0, behavior: 'auto' }); document.body.style.overflow = 'hidden'; setTimeout(() => { document.body.style.overflow = 'auto'; }, 500);
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Instant scroll with overflow toggle | Multiple style changes | 2 reflows | High paint cost due to layout shifts | [X] Bad |
| Native smooth scroll API | No extra DOM changes | 0 reflows | Low paint cost with smooth compositing | [OK] Good |