fix: load primary font in a non-blocking manner #448
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refs: CD-514
Types of changes
Description
Adds the
media="print"
attribute to the primary Google Fonts entry to load them in a non-blocking manner. The attribute gets stripped when JS is enabled and the file has loaded. Non-JS browsers will fail to load this font file entirely.I didn't touch the special fonts in our libraries definitions because the Arabic and Chinese fonts are more necessary to render text properly, so applying this JS-dependent optimization felt like a bad move. Happy to discuss if people disagree.
Steps to reproduce the problem or Steps to test
media="print" onload="..."
<link>
element to see if the DOM got modified to removemedia="print"
Impact
No impact. We already used
display:swap
on our fonts so the behavior is identical.PR Checklist