Change detection is the process through which Angular checks to see whether your application state has changed, and if any DOM needs to be updated.
NgZone (Angular execution context) is used to detect changes automatically. It is done using zone.js which patches standard web APIs.
It can be triggered manually (using ChangeDetectorRef) or automatically through an asynchronous event (more details).
At a high level, Angular walks your components from top to bottom, looking for changes.
Change detection is highly optimized and performant, but it can still cause slowdowns if the application performs it too frequently.
Optimization tips:
- Use the OnPush strategy.
- Use Angular Pipes for referentially transparent expressions.
- Run outside of NgZone async tasks that are not affecting the app view.
- Resolve zone pollution (use Angular DevTools to detect it).
- Configure zone.js.
- Pipe vs component method (usage).
- Async tasks.
- onProperty APIs.
- Zone pollution.
- Zone configuration.
- Noop NgZone (module based / standalone).
yarn install --frozen-lockfile