Angular · Performance · Frontend · TypeScript
Angular Performance with OnPush and Change Detection
Default versus OnPush change detection in Angular, what triggers an OnPush check, speeding up large lists with track and trackBy, and the most common mistakes.

In large enterprise Angular apps, the most common cause of "the page is slow" isn't the network; it's change detection running when it doesn't need to. If clicking a table row makes Angular re-check the whole app, users feel it as lag. This article covers the OnPush strategy and how to use it well.
What the Default strategy does
With the default strategy, whenever zone.js catches any async event (a click, a timer, an HTTP response), Angular checks the whole component tree from top to bottom. Fine in a small app; in a dashboard with hundreds of components, every mouse move gets expensive.
What OnPush changes
@Component({
selector: 'app-device-row',
changeDetection: ChangeDetectionStrategy.OnPush,
template: `{{ device().name }} · {{ device().status }}`
})
export class DeviceRowComponent {
device = input.required<Device>();
}
An OnPush component is checked only when:
- An input reference changes.
- An event fires in the component's own template.
- A signal read in the template changes, or the
asyncpipe receives a new value. markForCheck()is called manually.
Otherwise Angular skips the component and its subtree.
Immutability is required
The most confusing part of OnPush: mutate an object in place and Angular doesn't see it.
// Invisible: same reference
this.device.status = 'busy';
// Visible: new reference
this.device = { ...this.device, status: 'busy' };
So make immutable updates a habit when you work with OnPush. Signals make this much easier, because producing a new value with update becomes the natural flow. I cover combining signals and RxJS in Angular signals vs RxJS.
Large lists: use track
When re-rendering a list, if Angular can't tell which item is which, it recreates every DOM element. In the new control flow track is mandatory, and choosing the right key matters:
@for (device of devices(); track device.id) {
<app-device-row [device]="device" />
}
In the older *ngFor syntax, a trackBy function does the same job. Using track $index still causes needless re-renders when the list is sorted or filtered.
Don't call functions in templates
<!-- Runs on every change detection -->
<span>{{ formatUptime(device) }}</span>
This function runs again on every check. Use a pure pipe or a computed signal instead; both recompute only when inputs change.
Common mistakes
- Making a parent OnPush but leaving children on Default. When the parent is skipped, children aren't checked either, which is where "why doesn't it update" bugs come from. Be consistent.
- Calling
detectChanges()everywhere. It defeats the purpose of OnPush and usually hides an architectural problem. - Producing a new array for every realtime message. If a WebSocket sends dozens of messages a second, batch updates and apply them at intervals.
Measure
The Profiler tab in Angular DevTools shows how often and for how long each component is checked. Record the same scenario before and after switching to OnPush; the difference is usually striking.
Conclusion
OnPush, immutable data, the right track key and pipes or computed signals instead of template functions are the cheapest performance wins in large Angular apps. They are also the first step toward zoneless Angular.


