What if your app could scroll through thousands of items instantly without freezing?
Why Virtual scrolling for large lists in Angular? - Purpose & Use Cases
Imagine you have a long list of hundreds or thousands of items on a webpage, like a contact list or product catalog. You try to show them all at once by rendering every item in the browser.
Loading and rendering all those items at once makes the page slow and unresponsive. Scrolling becomes laggy, and the browser might even freeze or crash because it tries to handle too much data at the same time.
Virtual scrolling only renders the items visible on the screen plus a small buffer. As you scroll, it dynamically adds new items and removes those that go out of view. This keeps the page fast and smooth no matter how large the list is.
for (let item of items) { render(item); }<cdk-virtual-scroll-viewport> <div *cdkVirtualFor="let item of items">{{item}}</div> </cdk-virtual-scroll-viewport>It enables smooth, fast scrolling through huge lists without slowing down the app or overwhelming the browser.
Think of scrolling through your phone contacts app. Even if you have thousands of contacts, it feels instant and smooth because it only shows a few contacts at a time, loading more as you scroll.
Rendering all list items at once can crash or slow down your app.
Virtual scrolling renders only visible items to keep performance high.
This technique makes large lists feel fast and responsive.