Which JavaScript API efficiently detects when an element enters the viewport?
- A scroll event listener
- B IntersectionObserver
- C MutationObserver
- D ResizeObserver
Answer
IntersectionObserver
IntersectionObserver runs off the main thread and avoids the performance cost of a scroll handler firing continuously.





