When implementing infinite scroll, why is Intersection Observer preferred over scroll event listeners?
Intersection Observer is preferred for infinite scroll implementations because it significantly reduces performance overhead. Unlike scroll event listeners that fire continuously during scrolling (potentially hundreds of times per second), Intersection Observer only triggers when the observed element actually crosses specified thresholds. This results in better performance, smoother scrolling, and reduced battery consumption, especially on mobile devices. The API also handles all the complex calculations about element visibility, which would otherwise need to be manually computed in scroll event handlers.