NG.III · Angular 22 practice question
A frontend engineer is optimizing a dashboard page where a complex, rarely-used charting widget is present. To ensure the page loads quickly for the initial view, how should they implement the charting widget's loading mechanism?
@defer {
<complex-chart-widget />
}
Check answer and explanation
Correct answer: Wrap the widget in a `@defer` block to ensure its JavaScript bundle is fetched only after the initial page content is displayed.
Explanation
Wrapping the widget in a `@defer` block achieves the goal of deferring the loading of its code until it is actually needed, thereby improving initial load performance.
Common trap
Using the `async` pipe is for reactive data loading, not for controlling when the component's code is downloaded. `ngZone.runOutsideAngular()` is for performance optimization related to change detection, not bundle splitting.
Source: Angular docs: Deferred loading with `@defer` — Deferred loading with `@defer`
Checked against the cited text on 2026-11-25.