Skip to main content

Overview

Zoneless change detection eliminates the need for Zone.js, Angular’s traditional mechanism for automatic change detection. This results in smaller bundle sizes, better performance, and more predictable behavior.

Why Go Zoneless?

Smaller Bundle Size

Removing Zone.js can reduce your bundle size by ~30-50KB gzipped.

Better Performance

More efficient change detection with reduced overhead from zone tracking.

Improved Debugging

Easier debugging without Zone.js patching async operations.

Modern Primitives

Works seamlessly with Signals and reactive patterns.

Enabling Zoneless Mode

Use provideZonelessChangeDetection() to enable zoneless mode in your application.

Standalone Application

NgModule Application

Once you enable zoneless mode, Zone.js is completely removed from your application. Make sure your code is compatible before making the switch.

How It Works

Instead of automatically detecting changes after every async operation, zoneless mode relies on explicit change detection triggers:
  1. Signals: When signal values change
  2. Events: DOM event handlers
  3. Async Pipe: Observable emissions in templates
  4. Manual: Explicit ChangeDetectorRef calls

Migration Guide

Step 1: Use Signals for State

Replace component properties with signals where possible.

Step 2: Use Async Pipe for Observables

Always use the async pipe in templates for observables.

Step 3: Handle Async Operations

For callbacks and third-party integrations, manually trigger change detection.

Step 4: Update Event Handlers

Event handlers in templates automatically trigger change detection.

Advanced Patterns

Custom Change Detection Strategy

Zoneless Service with Signals

Testing Zoneless Applications

In zoneless mode, fixture.detectChanges() is deprecated. Use await fixture.whenStable() instead to wait for async updates.

Common Pitfalls

Avoid modifying component state in third-party callbacks without using signals or manual change detection.

Performance Optimization

Zoneless mode provides several performance benefits:
  • Reduced overhead: No Zone.js patches on async operations
  • Predictable timing: Change detection only runs when needed
  • Better tree-shaking: Smaller final bundle without Zone.js
  • Efficient updates: Fine-grained reactivity with signals

Best Practices

Prefer Signals

Use signals for all reactive state to get automatic change detection.

Use Async Pipe

Always use async pipe for observables in templates.

Avoid SetTimeout

Replace setTimeout/setInterval with observables or signals.

Test Thoroughly

Test your application extensively when migrating to zoneless.

Additional Resources