Performance: Pagination patterns
MEDIUM IMPACT
Pagination patterns affect how quickly users see content and how much data the browser processes at once, impacting load speed and interaction responsiveness.
const page = req.query.page || 1; const limit = 20; const items = await db.getItems({ skip: (page - 1) * limit, limit }); res.json(items);
const allItems = await db.getAllItems();
res.json(allItems);| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Load all data at once | High (many nodes) | Many reflows | High paint cost | [X] Bad |
| Paginate data per page | Low (few nodes) | Few reflows | Low paint cost | [OK] Good |