Link Relationships

HTML rel="preconnect"

Suggests opening an early connection to an origin, potentially covering DNS, transport and TLS. Connections have a cost; reserve this for important origins and match credential needs. 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="preconnect" href="https://assets.example.com" crossorigin>

Parameters & Attributes

NameTypeDescription
relspace-separated relationship tokensInclude preconnect on an element that supports this relationship.
hrefURL or fragmentIdentifies the linked destination or resource.
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="preconnect" href="https://assets.example.com" crossorigin>  </head>  <body>    <p>Example document</p>  </body></html>
HTML Reference