Question presented to candidate: "React 19 added resource preloading APIs. What are they, and what problem do they solve that a plain link tag does not?"
What a strong answer should cover:
- Six functions exported from
react-dom:preload,preinit,preconnect,prefetchDNS,preloadModule,preinitModule. - They let a component declare a resource need from inside component code, rather than requiring a hand-maintained list of tags in the document head.
preloadfetches and caches;preinitfetches and executes/applies. That is the key distinction — preinit a stylesheet and it applies, preinit a script and it runs.preconnectopens the connection (DNS, TCP, TLS) without fetching anything;prefetchDNSdoes only the DNS lookup — cheaper, for a host you might use.- React deduplicates calls, so calling from several components is safe.
- They work during SSR too, so the hints are emitted into the streamed HTML — earlier than any client-side effect could manage.
- Why it matters: the browser preload scanner cannot see resources that only a component knows it needs, so this closes a real gap.
- Judgement: preloading everything is counterproductive — it competes for bandwidth with what the page needs right now.
Clarifying questions expected:
- "Is the resource needed for this render, or a likely next navigation?" — that decides preload versus prefetch-style hints.
Code / implementation expected: Yes — calling them from a component, and inspecting what lands in the document head.