Description
In frontend/leaderboard.html, the fetchLeaderboardData() function currently fetches four independent leaderboard JSON files sequentially:
overall.json
monthly.json
weekly.json
daily.json
These files are fetched inside a for...of loop using await, so each request waits for the previous one to finish before starting.
Problem
The four JSON files are independent of each other, so they do not need to be fetched one by one. Sequential fetching can make the leaderboard load slower than necessary.
Proposed Solution
Replace the sequential for...of fetch loop with Promise.allSettled().
This will allow all four requests to start concurrently while still handling individual request failures safely.
Promise.allSettled() is preferred over Promise.all() because if one request fails, the other successful requests can still be used.
Expected Outcome
- Leaderboard JSON files are fetched concurrently.
- Loading performance improves.
- Failure of one leaderboard JSON request does not block the others.
- Existing leaderboard behavior remains unchanged.
File to Update
frontend/leaderboard.html
Description
In
frontend/leaderboard.html, thefetchLeaderboardData()function currently fetches four independent leaderboard JSON files sequentially:overall.jsonmonthly.jsonweekly.jsondaily.jsonThese files are fetched inside a
for...ofloop usingawait, so each request waits for the previous one to finish before starting.Problem
The four JSON files are independent of each other, so they do not need to be fetched one by one. Sequential fetching can make the leaderboard load slower than necessary.
Proposed Solution
Replace the sequential
for...offetch loop withPromise.allSettled().This will allow all four requests to start concurrently while still handling individual request failures safely.
Promise.allSettled()is preferred overPromise.all()because if one request fails, the other successful requests can still be used.Expected Outcome
File to Update
frontend/leaderboard.html