fontPreloadTag
The head link that preloads a font file: the browser starts the download before the stylesheet is read.
The head link that preloads a font file: the browser starts the download before the stylesheet is read.
Fonts are always fetched in CORS mode, so the link says crossorigin.
Import#
ts
import { fontPreloadTag } from "@shadow-js/dusk";
Signature#
ts
function fontPreloadTag(options: {
readonly href: string;
readonly type?: string;
}): HeadTag
Parameters#
| Name | Description |
|---|---|
options |
The font's URL and its MIME type (default font/woff2). |
Returns#
A head tag for useHead or document.head.
Throws#
- TypeError for a URL that is not a path or an http(s) URL.
Examples#
ts
import { fontPreloadTag } from "@shadow-js/dusk/static";
fontPreloadTag({ href: "/fonts/inter.woff2" }).props.as; // "font"