HTML & CSS · Senior · Question 73 of 75
Why prefer IntersectionObserver over scroll listeners for lazy loading or reveal effects?
- ✓Correct answer: It reports visibility changes asynchronously without forcing layout on every scroll event
- 2It works without JavaScript
- 3
scrollevents are deprecated
Explanation
Scroll handlers that call getBoundingClientRect() run dozens of times per second and can cause layout thrashing. The observer batches checks off the critical path.