Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Conversation

@federicobadini
Copy link
Contributor

closes #559

This PR moves font links (and other link/meta) from next/head to _document.tsx.
This enables nextjs font optimization.

QA

  1. Visit Vercel preview
  2. Verify that the font is not only linked, but that css @font-face instruction have been embedded in the page at build time

@vercel
Copy link

vercel bot commented Aug 2, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
react-commerce ✅ Ready (Inspect) Visit Preview Sep 2, 2022 at 9:03AM (UTC)
react-commerce-prod ✅ Ready (Inspect) Visit Preview Sep 2, 2022 at 9:03AM (UTC)

Copy link
Contributor

@davidrans davidrans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs for pages/_document are here: https://nextjs.org/docs/advanced-features/custom-document

Thanks for making this change @federicobadini!

CR ☕

@k0rvusk0r4x k0rvusk0r4x added the QAing Under QA team review label Aug 2, 2022
@k0rvusk0r4x
Copy link

Font is linked and css is there:
image

QA 😺

@k0rvusk0r4x k0rvusk0r4x removed the QAing Under QA team review label Aug 2, 2022
<Html>
<Head>
<link
href="https://fonts.googleapis.com/css2?family=Archivo+Black&family=Lato:wght@400;700&display=swap"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Google dislikes any second paint above the fold. It's likely setting font-display: optional would fix it (https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display)
Optional will force the first load of "slow" users to not use our font(s) and thus fallback to the browser defaults.
It's possible to style the browser defaults close to the actual font, which is what we do on the main site. It's a pain to style and may not be worth it right now.

Suggested change
href="https://fonts.googleapis.com/css2?family=Archivo+Black&family=Lato:wght@400;700&display=swap"
href="https://fonts.googleapis.com/css2?family=Archivo+Black&family=Lato:wght@400;700&display=optional"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what we have here in this pull is an improvement, so let's kick this suggestion to a new issue

@davidrans davidrans mentioned this pull request Aug 2, 2022
@davidrans davidrans merged commit 3ad6a77 into main Aug 2, 2022
@davidrans davidrans deleted the exploit-nextjs-font-optimization branch August 2, 2022 17:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Font performance: appears to be hurting LCP and TBT scores

5 participants