⚡ Performance Issue
The leaderboard runs a setInterval that fetches all data every 2 minutes regardless of whether the tab is visible or not — wasting bandwidth and API calls when the user has switched to another tab.
📍 Location
leaderboard.html — inline <script>
setInterval(fetchLeaderboardData, 2 * 60 * 1000);
✅ Fix
Use the Page Visibility API to pause polling when tab is hidden:
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
fetchLeaderboardData();
startPolling();
} else {
stopPolling();
}
});
let pollInterval;
function startPolling() {
pollInterval = setInterval(fetchLeaderboardData, 2 * 60 * 1000);
}
function stopPolling() {
clearInterval(pollInterval);
}
startPolling();
📁 File
leaderboard.html
🏷️ Labels
performance level:intermediate
⚡ Performance Issue
The leaderboard runs a
setIntervalthat fetches all data every 2 minutes regardless of whether the tab is visible or not — wasting bandwidth and API calls when the user has switched to another tab.📍 Location
leaderboard.html— inline<script>✅ Fix
Use the Page Visibility API to pause polling when tab is hidden:
📁 File
leaderboard.html🏷️ Labels
performancelevel:intermediate