Performance: Why real-time matters
HIGH IMPACT
This concept affects how quickly users see updates and interact with live data, impacting responsiveness and user experience.
const socket = new WebSocket('wss://example.com/chat');
socket.onmessage = event => renderMessages(JSON.parse(event.data));setInterval(() => {
fetch('/messages').then(res => res.json()).then(data => renderMessages(data));
}, 1000);| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Polling every second | High (updates every second) | High (layout recalculations each update) | High (repaints each update) | [X] Bad |
| WebSocket push updates | Low (only on new data) | Low (fewer layout recalculations) | Low (fewer repaints) | [OK] Good |