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

Google Fonts are not loading #35

Closed
karuppusamy-d opened this issue Apr 30, 2021 · 5 comments
Closed

Google Fonts are not loading #35

karuppusamy-d opened this issue Apr 30, 2021 · 5 comments

Comments

@karuppusamy-d
Copy link

Google fonts don't have onLoad="this.media='all'"

<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&amp;display=swap" media="print">

Firefox Dev Tools:

Firefox dev tools

@timlrx
Copy link
Owner

timlrx commented Apr 30, 2021

It's most probably a browser issue, not google fonts. I guess you don't see the inter font on the demo page?
https://tailwind-nextjs-starter-blog.vercel.app/

What version of firefox are you using? Preload works for firefox 85 onwards. https://caniuse.com/?search=preload

@karuppusamy-d
Copy link
Author

It's most probably a browser issue, not google fonts. I guess you don't see the inter font on the demo page?
https://tailwind-nextjs-starter-blog.vercel.app/

What version of firefox are you using? Preload works for firefox 85 onwards. https://caniuse.com/?search=preload

I am using latest Firefox@88, and it is not a browser issue.

onLoad on _document.js is handed on server side, if you inspect font link tag there will be no onload event

chrome dev tools

https://stackoverflow.com/questions/54278498/putting-event-handlers-inside-nextjs-document-and-relationship-between-nextj

@timlrx
Copy link
Owner

timlrx commented Apr 30, 2021

Ok this is the related issue: vercel/next.js#12984

Without the onload it will not load it asynchronously but it still displays fine on my side. Can I check that the demo page does not show the Inter font for you? If so then it might be how media or preload is treated differently across browsers.

Anyway, I am good with upgrading to next.js 10.2 and use their recommended automatic webfont optimization

@karuppusamy-d
Copy link
Author

I have just installed inter font on my pc, Now it is showing correctly for me.

@timlrx timlrx mentioned this issue May 1, 2021
@timlrx
Copy link
Owner

timlrx commented May 1, 2021

Bumped up nextjs to 10.2 and use the recommended automatic font optimization. This should fix the issue.

@timlrx timlrx closed this as completed May 1, 2021
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

No branches or pull requests

2 participants