Automattic / Automattic/jetpack
Boost: Preload fonts
- Dominant language
- PHP
- Stars
- 1.8k
- Forks
- 898
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 774
Description
originally filed by @gravityrail
PageSpeed detected opportunities to improve load speed by preloading fonts.
In this particular case, adding the following to a test plugin improved scores.
```php
add_action( 'wp_head', function() {
echo '';
}, -PHP_INT_MAX );
```
We can/should use the Lighthouse results themselves to "discover" which fonts can/should be preloaded on a given URL. Note the `type` and `crossorigin` attributes are required if the font is served from a CDN.
Separately we may want to modify CSS to serve fonts from the origin. Browsers now typically segment caches by origin anyway so there's no caching benefit to having a shared instance, and incurring the DNS cost may cancel out any CDN benefits.
Some initial exploration notes in the old repo in a comment here: 664-gh-Automattic/jetpack-boost
Contributor guide
Research direction
No current file or test is named. Start by reviewing the Lighthouse results and the exploration notes in the old Jetpack Boost repository comment, then determine how eligible fonts should be discovered for a URL. Done should include correct preload attributes for CDN-served fonts and a decision on the separate origin-serving proposal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100