Zoneless Angular and OnPush Change Detection

Angular 15 min min read Updated: Nov 16, 2026 Advanced
Zoneless Angular and OnPush Change Detection
Advanced Topic 1 of 5

How the Screen Updates

Change detection is Angular checking your data and updating the HTML. It must run at the right moments: after a click, a timer or an HTTP response.

Zone.js (the Old Way)

zone.js patches browser APIs (events, timers, promises). When any of them finishes, Angular runs change detection for the whole component tree. It is simple and works automatically, but it can do extra work and adds bundle size.

OnPush

With ChangeDetectionStrategy.OnPush a component is checked only when:

  • An input() value changed (new reference)
  • An event happened inside the component (click and so on)
  • A signal used in its template changed
  • An async pipe received a value
  • You call markForCheck()
typescript @Component({ selector: 'app-user-card', changeDetection: ChangeDetectionStrategy.OnPush, template: `<h3>{{ user().name }}</h3>`, }) export class UserCard { user = input.required<User>(); }
Tip: OnPush is a good default for every component. New projects from the CLI often already set it.

Immutable Updates

typescript // BAD with OnPush: same object reference this.user.name = 'Sam'; // GOOD: new object this.user = { ...this.user, name: 'Sam' }; // BEST: signals user = signal<User>({ id: 1, name: 'Ann' }); rename(name: string) { this.user.update(u => ({ ...u, name })); }

Going Zoneless

Signals tell Angular exactly what changed, so zone.js is not needed. Zoneless apps are smaller, faster and have cleaner stack traces. Angular is moving in this direction, and recent versions make it the recommended path for new apps.

Version note: Zoneless was experimental in v18-v19, developer preview in v20 and is the default direction of newer releases such as v21 and v22. In new CLI projects, check whether your app.config.ts already contains the zoneless provider and whether zone.js is listed in angular.json polyfills.
typescript import { provideZonelessChangeDetection } from '@angular/core'; export const appConfig: ApplicationConfig = { providers: [ provideZonelessChangeDetection(), // no zone.js provideRouter(routes), provideHttpClient(), ], };

Then remove zone.js from the polyfills array in angular.json (and from test polyfills) and uninstall it if you do not use it.

What Triggers an Update When Zoneless?

TriggerWorks?
Signal changes read in the templateYes
Template event listeners ((click))Yes
async pipe emitsYes
markForCheck() callYes
Input/output changes of componentsYes
A plain property changed in setTimeoutNo. Use a signal

Fixing Code That Relied on Zone.js

typescript // Breaks when zoneless: plain field count = 0; ngOnInit() { setInterval(() => this.count++, 1000); } // Fix: use a signal count = signal(0); ngOnInit() { setInterval(() => this.count.update(c => c + 1), 1000); }
typescript // Old code with RxJS subscribe and plain properties private cdr = inject(ChangeDetectorRef); this.service.getData().subscribe(d => { this.data = d; this.cdr.markForCheck(); // tell Angular to check this component }); // Better: toSignal(), signal.set(d), or the async pipe

Migration Checklist

  1. Make all components OnPush
  2. Replace mutable fields used in templates with signals
  3. Use async pipe or toSignal for observables
  4. Add provideZonelessChangeDetection()
  5. Remove zone.js polyfill and run all tests
  6. Check third-party libraries support zoneless (many UI libraries do now)
  7. Use the official zoneless migration schematic or guide on angular.dev if available for your version
Test in dev mode: Angular reports an error when a component updates state without telling the framework (for example ExpressionChangedAfterItHasBeenChecked). Read these errors, they point to the exact fix.

Conclusion

OnPush plus signals lets Angular update only what changed. With that foundation you can remove zone.js, ship less code and get predictable updates.

Quick Summary: OnPush + signals + provideZonelessChangeDetection() (remove zone.js).

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators