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

Move Google Fonts block out of head to defer loading. #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alph486
Copy link

@alph486 alph486 commented Dec 3, 2023

TL;DR - I recommended deferring the load of the font and CSS to improve First Contentful Paint and overall performance.

The default Google Font docs recommend you copy the font / css links into the . Per Google PageInsights, this is probably the highest contributor to First Contentful Paint (on mobile 700ms). Moving the style and fonts links to the tag and deferring their load enables a much faster First Contentful Paint by deferring the load. In the worst case (on my site at least) the resulting "flicker" for an extremely slow load of the CSS isn't too bad..probably because the default font isn't too wildly different than Poppins.

@JugglerX
Copy link
Contributor

JugglerX commented Dec 3, 2023

I wonder if there is a more elegant approach to improve this? Moving things to the bottom of the body is kind of a brute force approach. Cant we take advantage of something like preconnect, async, preload? I can see the google fonts snippet is out of date compared to the latest instructions. I didnt find anything about moving fonts to the bottom in these guidelines https://developer.chrome.com/docs/lighthouse/performance/render-blocking-resources/?utm_source=lighthouse&utm_medium=lr

@alph486
Copy link
Author

alph486 commented Dec 3, 2023

You might be right. I tried that initially but gave up because I'm less familiar with those directives' relationships and ran into issues. The problem in getting that working thus far might come from the dependency of the css on the font files.

I'm tinkering around with preload and pre connect for the fonts/styles to see if there's something better. Will report back.

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