-
Notifications
You must be signed in to change notification settings - Fork 645
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
Add the &display=swap
parameter to the end of your Google Fonts URL
#429
Comments
In head, if the font is cached: <script>sessionStorage.fontsLoaded&&document.documentElement.classList.add("wf-active");</script> And load webfontloader async with font-display: swap: if (!sessionStorage.fontsLoaded) {
require(['webfontloader'], function(WebFont) {
WebFont.load({
google: {
families: [
'Roboto:400,700&display=swap'
]
},
active: () => {
sessionStorage.fontsLoaded = true
},
});
});
} Google Lighthouse score Mobil: 100 Der gesamte Text bleibt während der Webfont-Ladevorgänge sichtbar. |
You can now optimize the whole thing with Preconnect / dns-prefetch. <link rel="dns-prefetch" href="//fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> Does anyone have more experience or tips here? |
May I add that in order for you can achieve this by doing const fonts = [ ... ] // what you'd normally pass to families: []
fonts.map((x, i) => x + variants + (i === fonts.length - 1 ? '&display=swap' : '')); Adding on each item in the array passed to families will generate a request with multiple display=swap params. |
Hi, Can you Add the &display=swap parameter to the end of your Google Fonts URL?
https://web.dev/font-display/?utm_source=lighthouse&utm_medium=unknown#google-fonts
This adds to the Google Lighthouse score
The text was updated successfully, but these errors were encountered: