Performance: Why file system access matters
MEDIUM IMPACT
File system access impacts server response time and overall backend processing speed, which indirectly affects frontend load times and user experience.
import fs from 'fs/promises'; app.get('/data', async (req, res) => { const data = await fs.readFile('./data.json', 'utf-8'); res.send(JSON.parse(data)); });
import fs from 'fs'; app.get('/data', (req, res) => { const data = fs.readFileSync('./data.json', 'utf-8'); res.send(JSON.parse(data)); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous file read in request handler | N/A | N/A | N/A | [X] Bad |
| Asynchronous file read with promises | N/A | N/A | N/A | [OK] Good |