- This topic has 7 replies, 2 voices, and was last updated 4 years, 8 months ago by
Elvin.
-
AuthorPosts
-
September 26, 2021 at 5:03 pm #1943771
Jacob
780 ms decrease in loading time when adding Vollkorn to my typography design from google font and occasional flickering upon page load also referred to as fout I believe.
What is best practice for adding Google Fonts to GeneratePress ?
Thank you.
September 26, 2021 at 6:50 pm #1943789Elvin
StaffCustomer SupportHi Jacob,
The best practice on any site generally is to use only 2-3 font families and try to remove unused variants. (less is better)
Example: If you’re using only font weights 400 and 600 regular (no italic), make sure the customizer doesn’t include 100,200,300,500,700,800,900 and italic variants of the font-family so it doesn’t get included when the site loads the Google stylesheet for it. This way, the site only loads what it needs. It’s more efficient. 😀
Consider preloading it as well. Optimization plugins usually have an option to do this for you. 🙂
September 26, 2021 at 7:50 pm #1943815Jacob
Thank you. I just followed your guide and I think I have it working. But it is frustrating.
FOIT – not FOUT as I wrote, sorry. https://web.dev/font-display/?utm_source=lighthouse&utm_medium=lr
But I do not want the swap-feature. That annoys me. Anyways, that that I have the google fonts locally hosted I hope it will suffice.
Thank you.
September 26, 2021 at 8:09 pm #1943828Elvin
StaffCustomer SupportBut I do not want the swap-feature. That annoys me. Anyways, that that I have the google fonts locally hosted I hope it will suffice.
In that case, then you really must preload the font assets.
This is so the font files are the first ones to load on the page, meaning the browser doesn’t have to hide the text while waiting for the font file to load.
This avoids “ensure text remains visible during web font load” flag because the browser doesn’t have to wait for the font as it is already loaded.
September 26, 2021 at 8:14 pm #1943833Jacob
Thank you so much, Elvin
September 26, 2021 at 8:32 pm #1943844Elvin
StaffCustomer SupportNo problem. 😀
September 27, 2021 at 12:23 am #1943946Jacob
The font I have chosen as default in my theme, is not reflected in the gutenberg editor ? Should it not be ? Do I need to add some code to have it used in the editor ?
September 27, 2021 at 1:27 am #1944006Elvin
StaffCustomer SupportThe font chosen for the theme only loads on the front end.
Gutenberg uses its own stylesheet meaning you’ll have to enqueue a stylesheet for font importation for it as well.
There are plugins like “Custom Fonts” or OMGF that lets you add fonts on Gutenberg but you can manually add this as well using
enqueue_block_editor_assetshook.Example:
add_action( 'enqueue_block_editor_assets', function() { wp_enqueue_style( 'your-handle', 'URL TO YOUR FILE' ); } );Where
URL TO YOUR FILEis the path to the stylesheet that contains your font importation CSS. 😀 -
AuthorPosts
- You must be logged in to reply to this topic.