Infinite Scrolling in Modern Web Apps
Infinite scrolling is one of the most commonly asked topics in coding interviews and widely used in real-world applications like social media feeds, e-commerce sites, and content platforms.
So for implementing the Infinite scroll we need to understand the intersection observer, so before jumping directly into Intersection Observer, it's important to understand some foundational concepts that power traditional infinite scrolling.
1. Understanding Viewport Height
What is window.innerHeight (Viewport Height)?
The viewport height is the visible area of the browser where content is displayed.
window.innerHeight
This gives the height of the visible screen (excluding browser UI like address bar)
What is document.documentElement.scrollHeight?
This represents the total height of the webpage, including content that is not currently visible (scrollable part).
document.documentElement.scrollHeight
What is document.documentElement.scrollTop?
This tells how much the user…