Question presented to candidate:
"Our product page ships the comments widget and a chart library in the main bundle even though most users never scroll to them. What are deferrable views in Angular, how do the @defer blocks fit together, and what happens at runtime?"
What a strong answer should cover:
@defer(v17, stable v18) lazily loads a part of a template and the code of the standalone components, directives and pipes inside it.- The companion blocks:
@placeholder,@loading,@error, withminimumandaftertiming options. - Triggers: default
on idle;on viewport | interaction | hover | timer(...) | immediate,when expr; plusprefetchvariants. - Runtime states: placeholder, then loading, then complete or error.
- Requirements and limits: dependencies must be isolated to split; a trigger without a target needs a
@placeholder. - SSR: the placeholder is server-rendered;
hydratetriggers change that.
Clarifying questions expected:
- "Do we render on the server? That changes what crawlers see inside the block."
- "Is the heavy code only used in this section, or imported elsewhere too?"
Code / implementation expected: Yes β a @defer block with placeholder, loading and error states.