Performance: EJS template setup
MEDIUM IMPACT
This affects the server-side rendering speed and initial page load time by how templates are compiled and served.
const cachedData = heavyComputation(); app.set('view engine', 'ejs'); app.get('/', (req, res) => { res.render('index', { data: cachedData }); });
app.set('view engine', 'ejs'); app.get('/', (req, res) => { res.render('index', { data: heavyComputation() }); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Render with heavy computation on each request | N/A (server-side) | N/A | Delays initial paint | [X] Bad |
| Render with precomputed data and cached templates | N/A (server-side) | N/A | Fast initial paint | [OK] Good |