Performance: res.render for templates
MEDIUM IMPACT
This affects server response time and how quickly the browser receives the fully rendered HTML page.
app.get('/', async (req, res) => { // Use async data fetching const data = await fetchDataAsync(); res.render('index', { data }); });
app.get('/', (req, res) => { // Render template with heavy synchronous logic const data = heavySyncDataProcessing(); res.render('index', { data }); });
| Pattern | Server CPU Usage | Response Size | Response Time | Verdict |
|---|---|---|---|---|
| Heavy synchronous data processing before res.render | High CPU blocking | Medium | Slow response, blocks event loop | [X] Bad |
| Async data fetching with minimal data passed to res.render | Low CPU non-blocking | Small | Fast response, non-blocking | [OK] Good |