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

♻️ Inter Font - Added preload to avoid FOUT issues #1623

Merged
merged 4 commits into from
Nov 6, 2024

Conversation

babakamyljanovssw
Copy link
Member

@babakamyljanovssw babakamyljanovssw commented Nov 6, 2024

Relates to #1600

This pull request includes updates to replace the @fontsource/inter package with @fontsource-variable/inter.

@fontsource-variable/inter version enables to use single font file that contains multiple variations of the same font, such as different weights, widths, and styles. Read more at docs - https://fontsource.org/docs/getting-started/variable

Also added preload option to improve performance by loading font file before they are acquired.
https://fontsource.org/docs/getting-started/preload
https://web.dev/articles/codelab-preload-web-fonts

image
Figure: preload link was added to header

Font updates:

  • gatsby-browser.js: Replaced @fontsource/inter with @fontsource-variable/inter.
  • gatsby-ssr.js: Added import for @fontsource-variable/inter and included a preload link for the woff2 (file that contains all font variations) font file in the onRenderBody function.
  • package.json: Updated the dependency from @fontsource/inter to @fontsource-variable/inter.
  • src/style.css: Changed the font-family to use "Inter Variable" instead of "Inter".

When refreshing the page in local, it becomes all white then the page is displayed (in production not like this). But the correct font is rendered. So I wasn't able to really test the current FOUT issue in local

47B84483-B985-4096-A3D4-C14430C4451E
Figure: Correct font is rendered in local

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