Performance: Passing data to templates
MEDIUM IMPACT
This affects the server response time and the browser's initial rendering speed by controlling how much data is sent and how templates are processed.
app.get('/profile', (req, res) => { const user = getUserFromDb(); res.render('profile', { user }); });
app.get('/profile', (req, res) => { const user = getUserFromDb(); res.render('profile', { user: user, allUsers: getAllUsersFromDb() }); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Passing all data to template | High (large DOM from extra data) | Multiple reflows due to large content | High paint cost | [X] Bad |
| Passing minimal required data | Low (smaller DOM) | Single reflow | Low paint cost | [OK] Good |