Paginated vs Virtualized List

Muhammad Akram
2 min readApr 3, 2024

--

Ideally, the purpose of both is to load more content

pagination vs virutalization

When it comes to displaying large amounts of data on web pages, like product listings or social media feeds, you need a way to manage it effectively. Two common approaches are pagination and virtualization, but they differ in how they handle data and user experience (UX).

Pagination

Pagination breaks down your data into smaller, more manageable chunks. Users navigate through these “pages” using buttons or numbers, typically seeing a fixed number of items on each page. Here are the different pagination styles:

  • Pages: Displays a limited set of items per page, requiring users to click “Next” or “Previous” to navigate.
  • Infinite Scroll: Content loads automatically as users scroll down, creating the illusion of an endless list.
  • Load More Button: Users click a button to fetch additional data, offering more control over loading new content.

The Downside of Pagination: DOM Overload

A common issue with pagination, is that as you append new data to the existing list, the number of DOM nodes (elements in the web page) increases. This can lead to performance problems, like slow scrolling and responsiveness, as the browser struggles to manage a growing number of elements.

Virtualization

Virtualization tackles this issue by taking a different approach:

  1. Smart Rendering: It only creates DOM nodes for the items currently visible in the viewport (the area users can see on their screen), regardless of how much data is downloaded.
  2. Recycling Nodes: As users scroll, virtualized lists reuse existing DOM nodes for newly visible items, minimizing DOM manipulation.

This approach keeps the DOM size small and ensures smooth scrolling performance, even for very large datasets.

To achieve virtualization we can use react-window library, rewrite of react-virtualized library by Brian Vaughn.

--

--