Preloading Resources with React APIs
You'll learn how React 19 introduces built-in APIs to preload critical resources without manually writing <link rel="preload"> tags in your HTML.
The Problem with Manual Preloading
Traditionally, if you wanted to hint to the browser that certain resources (fonts, stylesheets, images) should load early, you'd manually add <link> tags to your HTML or use imperative DOM manipulation. This was error-prone and disconnected from your component logic.
React's Declarative Preloading APIs
React 19 introduces preload() and preinit() functions from react-dom that let you declaratively tell React about resources that should be loaded ahead of time:
import { preload, preinit } from 'react-dom';
function MyComponent() {
// Preload a font file
preload('/fonts/custom-font.woff2', { as: 'font' });
// Preinit a stylesheet (loads AND executes)
preinit('/styles/critical.css', { as: 'style' });
return <div>Content that needs these resources</div>;
}
The Difference
preload(): Downloads the resource but doesn't execute/apply it yet. Good for fonts, images, or scripts you'll need soon.preinit(): Downloads and applies the resource immediately. Useful for critical stylesheets.
The Benefit
React manages these hints automatically—no duplicate requests if multiple components call the same preload, and the browser gets early hints while React is still rendering your tree. It's like telling a chef which ingredients to prep before you finish deciding the full menu.
Key Takeaway: Use preload() and preinit() from react-dom to declaratively hint resource loading directly in your components, replacing manual <link> tag management.