As noted in the web.dev article, Preload critical assets to improve loading speed, sending the preload links via Link HTTP response headers has a slight performance advantage over HTML link tags:
You can also preload any type of resource via the Link HTTP header:
Link: </css/style.css>; rel="preload"; as="style"
A benefit of specifying preload in the HTTP Header is that the browser doesn't need to parse the document to discover it, which can offer small improvements in some cases.
Since Optimization Detective is output-buffering the page, this can be very straightforward to implement. Instead of (or rather in addition to) doing this:
As noted in the web.dev article, Preload critical assets to improve loading speed, sending the preload links via
Link
HTTP response headers has a slight performance advantage over HTMLlink
tags:Since Optimization Detective is output-buffering the page, this can be very straightforward to implement. Instead of (or rather in addition to) doing this:
https://github.com/WordPress/performance/blob/2f2691a153cf1819a907a7cb54205d44c008bb62/plugins/optimization-detective/optimization.php#L192-L195
A new method can be added to
OD_Preload_Link_Collection
likesend_headers()
which can construct theLink
response header and send it viaheader()
.