Performance: Why understanding res matters
MEDIUM IMPACT
Understanding the response object (res) affects how quickly and efficiently the server sends data to the browser, impacting page load speed and user experience.
app.get('/data', async (req, res) => { // Offload heavy processing asynchronously const data = await heavyComputationAsync(); res.send(data); });
app.get('/data', (req, res) => {
// Doing heavy processing before sending response
const data = heavyComputation();
res.send(data);
});| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Blocking synchronous processing before res.send | N/A | N/A | Delays initial paint | [X] Bad |
| Asynchronous processing with prompt res.send | N/A | N/A | Faster initial paint | [OK] Good |