Link Relationships

HTML rel="preload"

Requests an important current-page resource early. Match the eventual request destination and credentials to avoid duplicate downloads; preload does not apply a stylesheet or execute code. The example belongs in a document head; resource URLs are illustrative. Supply actual resources and server configuration to observe network behavior.

Formal Syntax & Structure

html syntaxhtml
<link rel="preload" href="/fonts/main.woff2" as="font" type="font/woff2" crossorigin>

Parameters & Attributes

NameTypeDescription
relspace-separated relationship tokensInclude preload on an element that supports this relationship.
hrefURL or fragmentIdentifies the linked destination or resource.
asfetch destination keywordMatch the subsequent resource request, e.g. font, style, script or image.
crossoriginanonymous or use-credentialsControls eligible request credential settings. Match the actual use; font preloads require crossorigin.

Working Example

Example Snippethtml
<!doctype html><html lang="en">  <head>    <meta charset="utf-8">    <title>Example</title>    <link rel="preload" href="/fonts/main.woff2" as="font" type="font/woff2" crossorigin>  </head>  <body>    <p>Example document</p>  </body></html>
HTML Reference