Performance: How Express builds on Node.js HTTP
MEDIUM IMPACT
This concept affects server response time and how quickly the server can handle HTTP requests and send responses.
const express = require('express'); const app = express(); app.get('/data', (req, res) => { res.json({message: 'Hello'}); }); app.use((req, res) => { res.status(404).end(); }); app.listen(3000);
const http = require('http'); const server = http.createServer((req, res) => { if (req.url === '/data' && req.method === 'GET') { res.writeHead(200, {'Content-Type': 'application/json'}); res.end(JSON.stringify({message: 'Hello'})); } else { res.writeHead(404); res.end(); } }); server.listen(3000);
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Raw Node.js HTTP server | N/A (server-side) | N/A | N/A | [OK] Good for minimal overhead |
| Express server with middleware | N/A (server-side) | N/A | N/A | [!] OK with small overhead |