Performance: Flash messages
MEDIUM IMPACT
Flash messages affect page load speed and user interaction responsiveness by adding DOM elements and triggering reflows when shown or hidden.
Render flash messages conditionally only when present, and use CSS transitions with opacity for showing/hiding without layout changes.
In the layout, always render flash divs with content even if empty, and use JavaScript to show/hide them by toggling display styles on every page load.
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Always render flash divs and toggle display | High (extra nodes always present) | Multiple reflows per page load | High (layout changes trigger paint) | [X] Bad |
| Render flash divs conditionally and use opacity transitions | Low (only when needed) | Single reflow on insertion | Low (opacity changes only trigger paint/composite) | [OK] Good |