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

Adding custom font affects performance (LCP) a lot #382

Open
Baroshem opened this issue Nov 12, 2024 · 5 comments
Open

Adding custom font affects performance (LCP) a lot #382

Baroshem opened this issue Nov 12, 2024 · 5 comments
Labels
question Further information is requested

Comments

@Baroshem
Copy link

Hey there!

I am amazed by the DX of this module and how easy it is to add a new web font to your Nuxt project. I want to make my application as performant as possible and the problem is when I add a web font (instead of using default machine font) the performance of the app (and more specifically Largest Contentful Paint) drops a lot :(

I have added following code to my app:

<style lang="css" scoped>
#main {
  font-family: "Inter", sans-serif;
}
</style>

With Inter web font
Image

Image

Without Inter web font
Image

I looked at the https://web.dev/articles/font-best-practices and it seems that Nuxt Fonts implements all of it by default.

Is there anything that I am missing or is it how web fonts affect performance in general?

I will be grateful for any response or feedback :)

@Baroshem Baroshem added the question Further information is requested label Nov 12, 2024
@danielroe
Copy link
Member

can you provide a minimal reproduction? 🙏

@Baroshem
Copy link
Author

Baroshem commented Nov 12, 2024

@danielroe
Copy link
Member

in that case I don't believe the issue is the font - it's just capturing the slow load via LCP. This is the current lighthouse score without custom font:

Image

@Baroshem
Copy link
Author

Baroshem commented Nov 12, 2024

This is the old version of the page that does not come with many perf improvements. I cannot deploy a new version where you could see it due to following issue:
Image

Here are the most up to date reports (they are with the font commented out):

  1. https://storage.googleapis.com/lighthouse-infrastructure.appspot.com/reports/1731423186516-95911.report.html
  2. https://storage.googleapis.com/lighthouse-infrastructure.appspot.com/reports/1731423185413-73757.report.html
  3. https://storage.googleapis.com/lighthouse-infrastructure.appspot.com/reports/1731423185924-3418.report.html

@Baroshem
Copy link
Author

Baroshem commented Nov 12, 2024

Just to give you more context. In the CI script there is a job for doing Lighthouse test.

  1. After commenting out the font https://github.com/nuxt/commerce/commit/2b78b2149487371e8abbbd2efeac66548c0737b9
  2. Before commenting the font https://github.com/nuxt/commerce/commit/4b4928883950298fdd1768059cebb3abffe50647

The second link will have much worse score for all pages. The first one where the only change is commenting/removing font. With font added it seems to increase the Render Delay and increase overall Largest Contentful Paint time even though font-display and font face are used. under the hood.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants