Performance: Creating a basic Express server
MEDIUM IMPACT
This affects the initial page load speed and server response time, impacting how quickly the browser receives content to render.
const express = require('express'); const app = express(); app.get('/', (req, res) => { res.send('Hello World'); }); app.listen(3000);
const express = require('express'); const app = express(); app.use((req, res, next) => { // heavy synchronous task for(let i = 0; i < 1e9; i++) {} next(); }); app.get('/', (req, res) => { res.send('Hello World'); }); app.listen(3000);
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Heavy synchronous middleware | N/A (server-side) | N/A | N/A | [X] Bad |
| Minimal async route handler | N/A (server-side) | N/A | N/A | [OK] Good |