Performance: Server routes and API
MEDIUM IMPACT
This concept affects page load speed and interaction responsiveness by controlling how data is fetched and served from the backend.
app.get('/api/data', (req, res) => { const { page = 1, limit = 20 } = req.query; // Fetch only needed data with pagination const data = database.getPage(page, limit); res.json(data); });
app.get('/api/data', (req, res) => { // Fetch all data without pagination or filtering const data = database.getAll(); res.json(data); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Fetch all data at once | N/A | N/A | High due to large data rendering | [X] Bad |
| Paginated API requests | N/A | N/A | Low due to smaller data chunks | [OK] Good |