NG.III · Angular 22 practice question
A front-end engineer is implementing a dashboard widget that should only load its heavy data visualization component when the user is not actively interacting with other parts of the application. Which mechanism should they use to ensure the component is not rendered until the browser is idle?
@defer {
<HeavyVisualizationComponent />
}
Check answer and explanation
Correct answer: Wrap the component in a `@defer` block without any explicit trigger, relying on the default idle state.
Explanation
The appropriate method is to 'Wrap the component in a `@defer` block without any explicit trigger, relying on the default idle state.' This aligns with the source material, which indicates that a `@defer` block automatically activates when the browser enters an idle state.
Common trap
The suggestion to 'Use a `when: 'idle'` directive on the component tag to force lazy loading during idle periods' is flawed because the `@defer` syntax utilizes a `when:` attribute for specifying explicit conditions, rather than applying a directive directly to the element. Furthermore, 'Implement a custom `loadOnIdle` input property on the component itself' pertains to designing a component's interface, not utilizing the inherent lazy loading functionality.
Source: Angular docs: Deferred loading with `@defer` — `@defer`
Checked against the cited text on 2026-11-25.