Performance: Why data binding matters
MEDIUM IMPACT
Data binding affects how quickly the UI updates in response to data changes and how much work the browser does to keep the interface in sync.
Use OnPush change detection strategy and immutable data patterns, e.g., @Component({ changeDetection: ChangeDetectionStrategy.OnPush }) with inputs updated via new object references.Using two-way binding on many inputs without change detection optimization, e.g., <input [(ngModel)]="user.name"> repeated in large lists.
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Two-way binding on large lists | Many DOM updates per input | Multiple reflows per keystroke | High paint cost due to frequent updates | [X] Bad |
| OnPush with immutable data | Minimal DOM updates | Single reflow per change | Low paint cost | [OK] Good |