How can I make sure to use this CSS function? Google Pagespeed Insights recommends adding this. Is there a way to add this via custom code?
Just chiming in that I have this question too!
Why not? Just add your properties with any custom code method (for the whole site, for the page, with embed)
For those inquiring minds…
Webflow google font code using js:
Standard google font import code:
<link href="https://fonts.googleapis.com/css?family=Open+Sans&display=swap" rel="stylesheet">
I would also love to know the answer to @Ntchi 's question. Font-display=swap would help my site greatly it seems. Is there a way to directly access the CSS to make sure the swap is in there?
I would also like to know how I can use font-display: swap; with Webflow Font embed.
I’m also curious about this.
I would love to find out this!
Also trying to find a solution to this.
For those that did not visit the link and are asking how to do this with fonts loaded via the webfont,js library that Webflow uses the answer is : TL’DR => you can’t.
The article presents options for you if you want to load the fonts yourself or leverage Cloudflare service workers. Those would be the only two options for Webflow sites hosted on Webflow.
Awesome thanks. New to webflow forum and didn’t see that your previous comment with the link was the solution. Will check it out.
It seems that Webflow implemented “font-display: auto” to its css on hosted as well as on exported sites - wasn’t there a few weeks ago, I always added it manually to exported sites.
You can now edit this value to „swap“, „fallback“, etc when uploading a self hosted font!
I’ve been looking for a solution to this for a while now and this thread keeps popping up in my searches.
I found a way to make this happen for those looking for a no-code work arround. Just follow the steps below.
Download the open source font on Google Fonts
Extract the asset into your local x:/project/fonts/font-name folder
Upload the .TTF asset to font-squirl optimizer
Extract the .woff2 asset
Copy it to your local x:/project/fonts/font-name folder
Upload the assets to Webflow Settings → Font
Define your Font Family, display: swap, and fallback accordingly.
Run your speed test again and measure the improvements.
No more nagging fallback font reccomendation
Now crack open a beer, a soda, some coffee, or tea, take a sip and sigh in relief.
And that folks is the work around to getting Google Fonts to display swap.
Great job on this!! This worked for us, even with Montserrat. This brought us from a score of 70 (Webflow was loading 28 google versions of Montserrat) to score 95 (loading 3 Montserrat). Shame Webflow makes this such a hack job.
Just upload the compressed files manually as you said, then make sure you’re super precise with your fonts in the classes - if there’s a single mention of ie. Lato or something you don’t haven’t uploaded, Webfont will be back again. Ctrl + F your downloaded CSS as you said to remove all those mentions. The most extreme version of this to test agains is removing all mentions of any custom fonts on your classes, and setting the body to default (Arial).
In this case Webfont should not be called at all and our project performance was a 96 score (but it wasn’t pretty).
We ended up loading montserrat back in to custom fonts once compressed and are now at 95 score.
If it works correctly, the ones you haven’t uploaded will be greyed out as below.
Webfont is now not loaded at all now on ATMOS Financial | Green Banking Services for Climate-Friendly Checking and Sustainable Savings Accounts