What is virtual scrolling and when should you use it?
Model answer
Virtual scrolling (from the Angular CDK) renders only the items visible in the viewport plus a small buffer, and reuses elements as the user scrolls. This keeps the DOM small, so lists with thousands of rows stay fast.
Use it for very long lists or tables. Drawbacks: items usually need a known or estimated height, browser find-in-page cannot find rows that are not rendered, and accessibility needs care. For lists of a few hundred items, normal rendering with track is simpler.
Learn this topic
Angular Tutorial: Beginner to Advanced .
Sign in to add your own answer.
More questions
- Why is track important in @for (or trackBy in *ngFor)?
- What are the main ways to improve Angular app performance?
- Why is calling a method in a template expression a performance problem?
- What is NgOptimizedImage and what does it give you?
- What is server-side rendering (SSR), and why would you use it?
- What is hydration in Angular?