How does zone.js drive change detection and what changes with zoneless Angular?
Assesses fundamental understanding of Angular conventions, runtime behavior, and memory/performance considerations.
Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.
Historically Angular relied on zone.js, which monkey-patches async APIs such as setTimeout, promises, XHR and event listeners so the framework knows when something might have changed. Every async callback triggers ApplicationRef.tick(), which walks the component tree from the root; OnPush lets Angular prune subtrees whose inputs are unchanged.
Implications: frequent async work can cause many full checks, and work scheduled outside the zone, such as in a Web Worker callback or a non-patched library, will not update the UI unless you call NgZone.run or markForCheck. Conversely runOutsideAngular avoids needless detection for scroll or mousemove handlers.
this.zone.runOutsideAngular(() => {
el.addEventListener('scroll', onScroll, { passive: true });
});
Zoneless change detection removes the dependency and uses signals and explicit notification to schedule updates, improving performance and debuggability. The trade-off is that any non-signal async mutation must notify Angular explicitly.
Candidate Response Strategy & Interview Tips
- Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
- Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
- Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
- Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.