Performance: Event loop mental model
HIGH IMPACT
This concept affects how quickly Node.js can respond to events and handle asynchronous tasks without blocking the main thread.
const fs = require('fs'); fs.readFile('largefile.txt', (err, data) => { if (err) throw err; console.log('File read complete'); });
const fs = require('fs'); const data = fs.readFileSync('largefile.txt'); console.log('File read complete');
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous blocking code | N/A | N/A | N/A | [X] Bad |
| Asynchronous non-blocking code | N/A | N/A | N/A | [OK] Good |