Problem/Motivation
Followup from #3366561: Support preloading of fonts in the libraries API.
See also #3563782: [PP-1] Use early hints for CSS.
Before processing placeholders in HtmlResponseAttachmentsProcessor we can get the fonts out of the libraries available so far, and add early hints for fonts that specify they want them. This will allow the browser to start downloading critical render blocking assets as soon as humanly possible on slower pages.
Background reading:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/103
https://almanac.httparchive.org/en/2025/performance#early-hints-usage
Even at the turn of the year, early hints was seen on <5% of desktop pages so we will be pretty early adopters if we get this done.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|
Issue fork drupal-3570909
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
catchComment #3
catchBlocker is in.
Comment #4
catchComment #5
catchStarted to look at this, while Symfony does support early hints, it does so mainly via the web-link component which we don't have in core, so opened #3586585: Add Symfony's web-link component
Comment #6
catchLooked at the Symfony component, but don't think we need it - we can format the header with about three lines of code, and not sure about adding a
Linkclass to core when we already have one.Comment #7
catchMade a start.
ddev ships with nginx 1.26.3 and early hints support was added in 1.29.0 (https://blog.nginx.org/blog/nginx-introduces-support-103-early-hints) so I wasn't able to test this locally yet. Upgrading nginx or using apache + the http2 module ought to do it but not for today.
Also no idea what to do about testing - the code runs on more or less any request, but whether we can assert the 103 header in a functional test or not, no idea.
Comment #9
catchTests are passing, ran into problems trying to manually test this though.
Symfony only sends early hints header if the function
header_send()exists, which is from frankenphp.Actual PHP has a PR open to add early hints support, https://github.com/php/php-src/pull/7025 but until that's added and then Symfony adds support, we're out of luck on apache2 and nginx.
So this is at least soft-blocked on #3437187: Add Caddyfile configuration I think.
Moving to needs review for a code review though. Good news is that once PHP core + Symfony do support this for nginx/apache, then it should start working transparently.
Comment #10
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. The merge request has merge conflicts and cannot be merged. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.