Question presented to candidate: "Angular 18 announced zoneless change detection. What does zoneless mean, what replaces Zone.js as the trigger for rendering, and where do the performance gains actually come from? Is the Angular 18 story still accurate today?"
What a strong answer should cover:
- Zoneless means Angular does not use Zone.js to decide when to run change detection; a scheduler runs only after explicit notifications: signal changes read by templates, template/host events,
markForCheck()(and soAsyncPipe),setInput, views attached or removed. - Timeline: experimental in v18 (May 2024,
provideExperimentalZonelessChangeDetection), developer preview in v20.0, stable in v20.2 (provideZonelessChangeDetection), default in v21; in v22 Zone.js is opt-in withprovideZoneChangeDetection(). - Gains: no zone.js polyfill in the bundle, no change detection run per async task, native
async/await(no downlevelling), cleaner stack traces; biggest gains when combined with OnPush and signals. - Costs: code that mutated plain fields in callbacks goes stale;
NgZone.onStablelogic stops firing; SSR needsPendingTasksfor work Angular cannot see. - Can quote real numbers rather than "it is faster".
Clarifying questions expected:
- "Are we on an Angular version where zoneless is the default (v21+) or still opting in?"
- "Is state in signals already, or mostly plain fields and subscriptions?"
Code / implementation expected: Optional β a component showing which kinds of updates render without Zone.js.