Mouth
Well-known member
The preconnect relation is used to indicate an origin that will be used to fetch required resources. Initiating an early connection, which includes the DNS lookup, TCP handshake, and optional TLS negotiation, allows the user agent to mask the high latency costs of establishing a connection.
EXAMPLE
<linkrel="preconnect"href="//example.com">
<linkrel="preconnect"href="//cdn.example.com"crossorigin>
To initiate a preconnect, the user agent must run these steps:
The optimal number of connections per origin is dependent on the negotiated protocol, users current connectivity profile, available device resources, global connection limits, and other context specific variables. As a result, the decision for how many connections should be opened is deferred to the user agent.
Ref: http://w3c.github.io/resource-hints/#preconnect
EXAMPLE
<linkrel="preconnect"href="//example.com">
<linkrel="preconnect"href="//cdn.example.com"crossorigin>
To initiate a preconnect, the user agent must run these steps:
- Resolve the URL given by the href attribute.
- If that is successful, let preconnect URL be the resulting absolute URL, and otherwise abort these steps.
- If preconnect URL's scheme is not one of "http" or "https" then abort these steps.
- Let origin be preconnect URL's origin.
- Let corsAttributeState be the current state of the element's crossorigin content attribute.
- Let credentials be a boolean value set to true.
- If corsAttributeState is Anonymous and origin is not equal to current Document's origin, set credentials to false.
- Attempt to obtain connection with origin and credentials.
The optimal number of connections per origin is dependent on the negotiated protocol, users current connectivity profile, available device resources, global connection limits, and other context specific variables. As a result, the decision for how many connections should be opened is deferred to the user agent.
Ref: http://w3c.github.io/resource-hints/#preconnect
Upvote
12