Skip to content

perf: Paginate or lazy-render the "No Activity Yet" user section to prevent layout freezing on the last page #299

Description

@yashvi-3106

Description

When navigating to the very last page of the leaderboard, there is a severe performance freeze/lag. This is because all inactive users (those with a score of 0 in the overall leaderboard) are appended to the table at the same time without any pagination:

if (inactiveList.length > 0 && (currentPage === totalPages || isSearching)) {
  inactiveList.forEach((user) => {
    body.appendChild(renderLeaderboardRow(user, ""));
    mobileCards.appendChild(renderMobileCard(user, ""));
  });
}

As the database of registered users grows, this results in hundreds of DOM node insertions simultaneously, causing the browser thread to lock up.

To Reproduce

Navigate to the /leaderboard.
Click on the last page number in the pagination.
Observe the layout freeze / render lag.

Suggested Fix

Move inactive users to a separate, dedicated "Inactive Users" tab to prevent loading them on the primary leaderboard view.
Alternatively, paginate the inactive list separately so they are loaded incrementally

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions