preload
Starts fetching a resource the page will need, at high priority.
Starts fetching a resource the page will need, at high priority. The browser stores it for the
later request with the same URL and destination (React's preload).
Import#
ts
import { preload } from "@shadow-js/web";
Signature#
ts
function preload(href: string, options: PreloadOptions): void
Parameters#
| Name | Description |
|---|---|
href |
An http(s) or relative URL. |
options |
The destination (as, required) and the optional type, media and CORS mode. |
Throws#
- TypeError (production message
SHADOW_RESOURCE_HINT_URL) for a URL that is not http(s) or relative.
Examples#
ts
import { preload } from "@shadow-js/web";
preload("/fonts/inter.woff2", { as: "font", type: "font/woff2", crossOrigin: "anonymous" });