Replies: 1 comment
-
This would be really cool. We are seeing suboptimal lighthouse scores because of this. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
No response
Background
Currently either all or none of the files for a font are preloaded. Sometimes it makes sense to only preload some variants, and only load others when needed (for example italics or rarely used weights).
This is especially useful when using variables to style
<b>
or<i>
elements.The current workaround for this would look like this:
It is required to define the font-family for the
<i>
-tag to use the correct font. But this can cause problems when the<i>
is wrapped in a parent with a different font-family, which might have an italic variant already.Proposal
A possible solution is to define the font like this:
This will only preload the commonly used variants, without the need to change the font-family for the others and avoiding the inheritance problem described above.
This is a small change and I have a proof of concept PR ready: canary...darthmaim:next.js:feature/font-local-src-preload
Beta Was this translation helpful? Give feedback.
All reactions