---
title: "Angular Performance with OnPush and Change Detection"
description: "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."
url: https://sanderyaz.com/en/blog/angular-onpush-performance/
author: Sander Yazıcıoğlu
date: 2026-12-02
updated: 2026-12-02
lang: en
tags: ["Angular","Performance","Frontend","TypeScript"]
---

# Angular Performance with OnPush and Change Detection

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

```ts
@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:

1. An **input reference** changes.
2. An event fires in the component's own template.
3. A **signal** read in the template changes, or the `async` pipe receives a new value.
4. `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.

```ts
// 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](/en/blog/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:

```html
@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

```html
<!-- 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.

---

About the author: [Sander Yazıcıoğlu](https://sanderyaz.com/en/about/). Sander Yazıcıoğlu is a Senior Full-Stack Developer in Istanbul. At LiveTesting he builds the backend, frontend, realtime systems and Appium automation of a real-device testing platform; before that he built enterprise Angular apps at Testinium and Loadium.
