You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately there doesn't appear to be a way to pass this configuration to webfontloader which I believe is responsible for assigning the @font-face definitions.
I found myself in the same position and decided I'll host the webfont CSS myself for now.
I wrote a small script that downloads the webfont CSS from Typekit and adds font-display automatically, in case it is helpful for anyone: https://github.com/swissspidy/local-webfont
Reacted by Jón Trausti, Lauren Gray, MrPropre, Peder Klev, Alejandro Martín Parra, Adam Voliva, Pedr Browne, cameleater, Alexey Vorobyov, Misael Taveras and 6 more
Reacted by Oskar, Matthew Robitaille, Misael Taveras, Tommy Dunn, Milan Petrović, Márcio Duarte, Valker Vieira, Chris Heath, Panagiotis Skarlas, Andy and 5 more
Please stop adding "+1" responses, they're not useful in anyway and just clog up the issue thread with noise.
Instead 👍 the issue up top like many others are doing. Thanks.
Reacted by cameleater, Niels Gerritsen, Oskar, Kevin Sylvestre, Denis Belevtsov, Peter Arendt, Misael Taveras, Romain Francony, Dylan Bowers, Márcio Duarte and 13 more
I'm not sure about TypeKit, but we are shipping font-display support to Google Fonts soon which will hopefully avoid needing extra steps to locally host. This could be passed through configuration to webfontloader the same way the font-family currently is.
Reacted by Éric NICOLAS, Martijn Lafeber, Chris Lagasse, Misael Taveras, Abhishek Kakade, Brndn, Juan Ferreras and Miguel Montalvo
Reacted by Alexander Lichter, Brennan Kinney, Michael Walsh, Martijn Lafeber, Brndn and Miguel Montalvo
Is there a way to set the new &display=swap parameter for Google Fonts in Webfontloader?
Reacted by Mikhail Alferov, Casey Picker, Sergei Rogachev, Brandon, steveooo9, Adam Bunch, Stas Persiyanenko, Dennis Andersson, ws420, Zack Wallace and 11 more
I'm not sure about TypeKit, but we are shipping font-display support to Google Fonts soon which will hopefully avoid needing extra steps to locally host. This could be passed through configuration to webfontloader the same way the font-family currently is.
@addyosmani Can you give an example of how this might be done using webfontloader?
Reacted by Brandon, steveooo9, Kumiko Lange, Adam Bunch, Dennis Andersson and Alexander Eneroth
Reacted by Casey Picker, Lubomír Blažek, Marc Mogdanz, Pascal Sthamer, Josiah Nunemaker, Adam Czogallik, Alexander Maughan, Lauren Gray, ws420, codeguru and 12 more
Reacted by Oskar, Thomas Ehrig, Bryan Casler, Luca Iaconelli and TaiPham-Persol
@pmpr-ir
I found that by separating the families in the array does work and does not render the body-class wrong. It does not work when adding &display=swap or any other value behind the first two families. It only works when adding it to the last item in the array.
Both would provide a way to be more explicit when requesting the fonts with their associated styles and the desired display value. Although I can see how this could be a compatibility issue with previous implementations of the WebFont loader.
What are your thoughts on this?
I have upvoted your referenced pull request!
Edit: I just realized that both examples would result in two separate requests. How silly of me.
The trick, at least for me is to put the &display=swapONLY on the last font.
Reacted by Misael Taveras, Mtx Z, Pavel Petržela, Lourens de Villiers, Mikhail Kobzarev, Lucas Pelegrino, JP Santos, Jackie Luc, Carlos Cuesta, Faizan Baig and 2 more
So the URL is clearly built from the parameters.
(Before, I was using to get the same result <link href="https://fonts.googleapis.com/css?family=Hind:400,600,700|Ubuntu:700&subset=latin-ext&display=swap" rel="stylesheet">).
Activity
raRaRa commentedon Jan 3, 2019
+1. Shouldn't be that hard to add as opt-in, or even make it default with opt-out config?
swissspidy commentedon Jan 3, 2019
I found myself in the same position and decided I'll host the webfont CSS myself for now.
I wrote a small script that downloads the webfont CSS from Typekit and adds
font-displayautomatically, in case it is helpful for anyone: https://github.com/swissspidy/local-webfontsuperp commentedon Feb 4, 2019
+1
vguenichon commentedon Mar 29, 2019
+1
gilbertlucas41 commentedon Mar 31, 2019
+1
gagikm commentedon Apr 11, 2019
+1
waters01 commentedon Apr 12, 2019
+1
polarathene commentedon Apr 16, 2019
Please stop adding "+1" responses, they're not useful in anyway and just clog up the issue thread with noise.
Instead 👍 the issue up top like many others are doing. Thanks.
addyosmani commentedon May 11, 2019
I'm not sure about TypeKit, but we are shipping font-display support to Google Fonts soon which will hopefully avoid needing extra steps to locally host. This could be passed through configuration to webfontloader the same way the font-family currently is.
mmalferov commentedon May 14, 2019
Google already understands the 'display' parameter. Is there any hope that this option will be available in WFL?
https://fonts.googleapis.com/css?family=Roboto:400,700%7CRoboto+Condensed:400,700&subset=latin,cyrillic&display=swap
steveooo9 commentedon May 15, 2019
Is there a way to set the new
&display=swapparameter for Google Fonts in Webfontloader?ckpicker commentedon May 15, 2019
@addyosmani Can you give an example of how this might be done using webfontloader?
Cinamonas commentedon May 15, 2019
As a temporary solution, instead of
googlemodule, I’m usingcustomto specify the font:SamXronn commentedon May 16, 2019
Looks like Google Fonts and other third parties are starting to support this no news from Typekit disappointing.
rawksteady commentedon May 21, 2019
Similar to @Cinamonas example above, I've noticed you can also get away with doing the following:
Though I must admit it feels pretty hacky.
Update: This seems to have some issues with multiple font families, see @tzjoke answer below.
tzjoke commentedon May 22, 2019
@rawksteady It seems that your approach does not support multi fonts while @Cinamonas 's one does.
Update: @rawksteady Oh my bad, it does work.
But this case does not work:
From Network tab:
rawksteady commentedon May 23, 2019
@tzjoke Gotcha! Like I said, felt pretty hacky.
EmielZuurbier commentedon Jun 12, 2019
@pmpr-ir
I found that by separating the families in the array does work and does not render the body-class wrong. It does not work when adding
&display=swapor any other value behind the first two families. It only works when adding it to the last item in the array.This resolves to the URL below:
https://fonts.googleapis.com/css?family=Arimo:400,400i,700%7CDidact+Gothic%7CPlayfair+Display:400,400i,700&display=swap
Would prefer a built in setting or property to specify the font-display value per loaded font.
MrPropre commentedon Jun 13, 2019
&display=swaphack doesn't work on Edge browser.EmielZuurbier commentedon Jun 26, 2019
@pmpr-ir That too would be a feature that is very welcome. Maybe a syntax like the following would be a nice way to write it down?
Or maybe:
Both would provide a way to be more explicit when requesting the fonts with their associated styles and the desired display value. Although I can see how this could be a compatibility issue with previous implementations of the WebFont loader.
What are your thoughts on this?
I have upvoted your referenced pull request!
Edit: I just realized that both examples would result in two separate requests. How silly of me.
Szymon-dziewonski commentedon Aug 12, 2019
Any update on this? Thanks
mylesthedev commentedon Sep 6, 2019
+1
taverasmisael commentedon Sep 8, 2019
I've made it work with the following config:
The trick, at least for me is to put the
&display=swapONLY on the last font.mtx-z commentedon Sep 30, 2019
@taverasmisael is correct.
This config:
Generates a CSS get to:
So the URL is clearly built from the parameters.
(Before, I was using to get the same result
<link href="https://fonts.googleapis.com/css?family=Hind:400,600,700|Ubuntu:700&subset=latin-ext&display=swap" rel="stylesheet">).CSS file have the font-display:swap; for both.
https://fonts.googleapis.com/css?family=Hind:400,600%7CUbuntu:700&subset=latin-ext,latin-ext&display=swap:
storm-sec commentedon Feb 15, 2020
Hi there,
it is possible to fix webfont.js directly. For example, you can use dynamic integration (generated code for multiple fonts) without problems. Check this out: https://heiko-frenzel.de/fix-web-font-loader-pagespeed-insights-15782/
Cheers!