There is a common belief among Angular developers that switching to ChangeDetectionStrategy.OnPush will automatically improve application performance.
But is that really true?
Not necessarily, OnPush is an effective change detection optimization, but it is not a complete performance solution. Its effectiveness depends on how data flows through the application, how component inputs are managed, and how asynchronous operations are handled.
Practices such as immutable state updates, efficient list rendering, controlled subscriptions, and proper component design play an important role in achieving the expected performance improvements.
Let's understand how OnPush works and explore the common development practices that can affect Angular application performance, even when OnPush is enabled.

OnPush Change Detection: Key Practices for Better Angular Performance
How OnPush Change Detection Works?
Angular uses change detection to determine when the UI needs to update. With eager change detection, Angular checks a component whenever it reaches that component during a change detection cycle. With OnPush, Angular can skip component subtrees that don’t need to be checked.
Angular can check an OnPush component when:
- It receives a changed input through a template binding.
- An event occurs within its subtree.
- An observable emits a new value through the async pipe.
- A signal read by the component’s template changes.
- The component is explicitly marked for checking with ChangeDetectorRef.markForCheck().
The example below shows how to configure a product component to use OnPush.
@Component({
selector: 'app-product',
template: `{{ product.name }}`,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ProductComponent {
@Input() product: any;
}
Why OnPush Alone Doesn't Guarantee Better Performance?
Performance issues usually come from how data flows and how components are written, not just change detection strategy.
Let’s look at the common reasons and how to fix them.
1.Data Mutation
What happens:
Angular uses input reference/value comparisons rather than deeply comparing object properties when determining whether an input has changed. When an existing object is mutated without changing its reference, an OnPush child component may not be checked as a result of that input change.
updateQuantity(product: any) {
product.quantity++; // Mutates the existing object
}
How to fix it:
Always create a new object reference instead of mutating.
updateQuantity(product: any) {
this.products = this.products.map(p =>
p.id === product.id
? { ...p, quantity: p.quantity + 1 }
: p
);
}
This creates a new array and a new object for the updated product. As a result, Angular can recognize the changed input reference and update the relevant component.
2. No trackBy in Lists
What happens:
When rendering large collections, Angular needs to identify which data items correspond to existing DOM elements.
Without a stable tracking strategy, changes to object references can cause unnecessary DOM recreation.
<div *ngFor="let item of items">
{{ item.name }}
</div>
How to fix it:
Use trackBy to track items efficiently.
App.component.html
@for (item of items; track item.id) {
<div>{{ item.name }}</div>
}
3. Heavy Logic Inside Templates
What happens:
Functions or calculations inside templates run repeatedly during change detection, increasing load.
<p>{{ calculateTotal(product) }}</p>
How to fix it:
Move logic to component and reuse computed values
totals: Record<number, number> = {};
ngOnInit() {
this.products.forEach(p => {
this.totals[p.id] = p.price * p.quantity;
});
}
Modern Angular applications, the @for block uses a track expression to identify items and maintain their relationship with DOM elements. For existing applications using *ngFor, the trackBy function serves the same purpose.
4.Too Many Manual Subscriptions
What happens:
Manual subscriptions are useful when application logic needs to react to observable emissions. However, unmanaged subscriptions can introduce problems such as:
- Memory leaks when subscriptions are not cleaned up.
- Duplicate subscriptions performing the same work.
- Unnecessary updates to component state.
- Additional maintenance complexity.
this.service.getData().subscribe(data => {
this.data = data;
});
How to fix it:
Use async pipe to manage subscriptions automatically.
data$ = this.service.getData();
app.html
<div>{{ data$ | async | json }}</div>
5. Multiple async Pipes on Same Observable
What happens:
Every async pipe instance manages its own subscription.
Using multiple instances of the same observable in a template can therefore create multiple subscriptions.
For cold observables, such as Angular HTTP observables, multiple subscriptions can trigger multiple HTTP requests unless the observable is shared.
<p>{{ (user$ | async)?.name }}</p>
<p>{{ (user$ | async)?.email }}</p>
How to fix it:
Use a single async and reuse data.
<ng-container *ngIf="user$ | async as user">
<p>{{ user.name }}</p>
<p>{{ user.email }}</p>
</ng-container>
6. No Lazy Loading
What happens:
Loading all application features during the initial application load can increase the initial JavaScript bundle size.
This can increase download, parsing, and execution time, affecting the initial loading experience.
imports: [ AdminModule, ReportsModule ];
How to fix it:
Use lazy loading to load modules only when needed.
const routes: Routes = [
{
path: 'admin',
loadChildren: () =>
import('./admin/admin.module').then(m => m.AdminModule)
}
];
For applications using standalone components, use loadComponent or loadChildren with dynamically imported route configurations.
To dive deep into lazy loading refer my previous Article:
https://www.aptuz.com/blog/angular-lazy-loading-guide-boost-app-performance/
7. Too Many Change Detection Triggers
What happens:
Frequent events like scroll or input trigger repeated change detection.
window.addEventListener('scroll', () => {
this.handleScroll();
});
How to fix it:
Control frequency using RxJS operators
fromEvent(window, 'scroll')
.pipe(throttleTime(200))
.subscribe(() => {
this.handleScroll();
});
8. Passing Large Objects to Child Component
What happens:
Passing large objects to child components is not automatically expensive because Angular does not deeply compare every property of an input object.
However, passing unnecessary data can increase application complexity and lead to unnecessary child component dependencies, repeated data processing, and unnecessary input reference changes.
<app-child [data]="fullObject"></app-child>
How to fix it:
Pass only required data.
<app-child [id]="item.id" [name]="item.name"></app-child>
9.Large Component Trees
What happens:
As the component tree grows, change detection and rendering can become more expensive if components perform unnecessary work.
OnPush helps Angular skip eligible component subtrees, but it does not eliminate all view traversal.
Angular still needs to traverse relevant parts of the view hierarchy to determine which components require checking
<app-parent>
<app-child>
<app-sub-child>
<app-deep-child></app-deep-child>
</app-sub-child>
</app-child>
</app-parent>
How to fix it:
Break into smaller, independent components.
Deep Insight: OnPush reduces unnecessary component checks, but it does not eliminate the need for Angular to traverse relevant parts of the component tree.
<app-product-list></app-product-list> <app-user-summary></app-user-summary>
10.Not Using Signals (Modern Angular)
What happens:
Traditional component state management often relies on properties and observable subscriptions.
As applications grow, managing state updates across multiple components can become more complex.
Signals provide a reactive approach that allows Angular to track which components depend on specific state values.
count = 0;
increment() {
this.count++;
}
How to fix it:
Use Angular Signals for fine-grained reactivity.
When a signal read in an OnPush component's template changes, Angular marks that component for checking. This helps Angular update the components that depend on the changed signal without unnecessarily checking unrelated OnPush components
import { signal } from '@angular/core';
count = signal(0);
increment() {
this.count.update(v => v + 1);
}
<p>{{ count() }}</p>
11. Zone.js Still Triggers Change Detection
What happens:
In traditional Zone.js-based Angular applications, Zone.js monitors asynchronous operations such as:
- setTimeout
- Browser events
- Promise callbacks
- Other patched asynchronous APIs
These operations can notify Angular that application synchronization may be required.
However, this does not mean every OnPush component is automatically checked. Angular still applies its change detection rules and can skip eligible OnPush subtrees.
setTimeout(() => {
this.heavyCalculation();
}, 1000);
How to fix it:
Run heavy or non-UI logic outside Angular’s zone.
This prevents Angular from running change detection unnecessarily.
constructor(private ngZone: NgZone) {}
runTask() {
this.ngZone.runOutsideAngular(() => {
this.heavyCalculation();
});
}
In traditional Zone.js-based applications, Zone.js helps notify Angular about asynchronous activity. OnPush still determines which component subtrees need to be checked.
12.Inefficient API Handling
What happens:
- Improper API handling can affect both application performance and backend resources.
- Common issues include:
- Triggering duplicate HTTP requests.
- Fetching the same data repeatedly.
- Updating component state unnecessarily.
- Making API calls when existing data can be reused.
this.api.getData().subscribe(data => {
this.data = data;
});
How to fix it:
- Cache API responses
- Share data using RxJS (like shareReplay)
Avoid duplicate API calls
data$ = this.api.getData().pipe(shareReplay(1));
<div *ngFor="let item of data$ | async">
{{ item.name }}
</div>
Conclusion: Building Faster Angular Applications with OnPush
OnPush helps improve Angular performance, but it is not a complete solution. Application performance also depends on efficient data handling, templates, component design, subscriptions, API calls, and change detection.
Combining OnPush with these practices helps build applications that are efficient and maintainable. The key is to identify actual performance bottlenecks and optimize where needed, rather than applying techniques blindly.
The goal is simple: make Angular do the right work at the right time, with minimal unnecessary processing.