Early Hints
Early Hints help the browser to load webpages faster. Early Hints is enabled automatically on all pages.dev
domains and custom domains.
Early Hints automatically caches any preload
and preconnect
type Link
headers to send as Early Hints to the browser. The hints are sent to the browser before the full response is prepared, and the browser can figure out how to load the webpage faster for the end user. There are two ways to create these Link
headers in Pages:
Early Hints can be created with either of the two methods detailed below.
Create custom headers using the _headers
file. If you include a particular stylesheet on your /blog/
section of your website, you would create the following rule:
Pages will attach this Link: </styles.css>; rel=preload; as=style
header. Early Hints will then emit this header as an Early Hint once cached.
In order to make the authoring experience easier, Pages also automatically generates Link
headers from any <link>
HTML elements with the following attributes:
href
as
(optional)rel
(one ofpreconnect
,preload
, ormodulepreload
)
<link>
elements which contain any other additional attributes (for example, fetchpriority
, crossorigin
or data-do-not-generate-a-link-header
) will not be used to generate Link
headers in order to prevent accidentally losing any custom prioritization logic that would otherwise be dropped as an Early Hint.
This allows you to directly create Early Hints as you are writing your document, without needing to alternate between your HTML and _headers
file.
Remove any automatically generated Link
headers by adding the following to your _headers
file: