Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: load primary font in a non-blocking manner #448

Merged
merged 1 commit into from
Dec 18, 2023
Merged

Conversation

rupl
Copy link
Contributor

@rupl rupl commented Dec 15, 2023

Refs: CD-514

Types of changes

  • ✔️ Improvement (non-breaking change which iterates on an existing feature)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Security update (dependency updates, or to fix a vulnerability)

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

  1. View source and see if the markup comes down the pipe with media="print" onload="..."
  2. Inspect the same <link> element to see if the DOM got modified to remove media="print"

Impact

No impact. We already used display:swap on our fonts so the behavior is identical.

PR Checklist

  • I have followed the Conventional Commits guidelines.

@rupl rupl requested review from orakili and left23 December 15, 2023 09:08
@rupl rupl merged commit 5ab531d into develop Dec 18, 2023
1 check passed
@rupl rupl deleted the CD-514-font-perf branch December 18, 2023 09:09
rupl added a commit that referenced this pull request Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants