Loading...
function App() {
preload('/fonts/inter.woff2', { as: 'font' });
return <Page />;
}function App() {
preload('/fonts/inter.woff2', { as: 'font', crossOrigin: 'anonymous' });
return <Page />;
}Fonts are always fetched in CORS mode, so the preload needs crossOrigin to match and avoid a second download.
crossOrigin and seeing it fetched twice.preload is imported from 'react-dom' and always gets the as option, such as 'font', 'image' or 'style'.crossOrigin, otherwise the font is downloaded twice.Both start a download early. preload() can be called from any component, and React removes duplicates and places the tag in the document head.
Yes. During server rendering React adds the preload to the HTML head; on the client it inserts the tag when the code runs.