Infinite scroll with IntersectionObserver instead of scroll event math
@devsingh05▲ 5 net votes
Place a sentinel element after the list and observe it with IntersectionObserver; when it becomes visible, load the next page. This avoids scroll listeners and layout thrashing. Guard against duplicate loads while a request is in flight, stop observing when there are no more pages, and use cursor pagination on the backend. For very long lists, virtualise rendering.