Fine tuning which font files are loaded

Hi,

I’m working on reducing the number of resources loaded on my site.

Part of this effort is taking a close look at which fonts are loaded.

In the theme options’ typography settings, I’ve selected Lato and Montserrat. I noticed this adds a link tag to the head of all pages that loads Lato 400, 400 italic, 700 and 700 italic etc. The same is true when I use the font manager. I never use italic fonts, so I would prefer to not load them.

Is it possible to stop X from adding this link tag? It seems to me that it would be easiest if I could add a link tag with all the fonts necessary myself, so I can fine tune which ones are loaded.

Thanks in advance for your help!

Hi @FreekR,

Thanks for reaching out.

The italic is added as part of one single request, it has no multiple requests. Plus, you can disable it from your font settings. Would you mind providing your site’s URL and admin login credentials? I’ll check if it’s cache related.

Thanks!

Hi Rad,

Thanks for your reply.

I understand that it’s a single request. However, it does matter which font weights etc. are loaded for speed optimization, correct? So what I want to do is change that one request to not include italic.

When you write font settings, do you mean the font manager? I can’t find a setting where I can prevent X theme from loading the fonts.

Thanks for your help.

Hi @FreekR,

Yes, it would help to reduce the loading time but it has no noticeable effect since the fonts are not loaded from your site, it’s loaded from Google CDN. So I thought you just meant reducing the number of requests as initially provided. Still, it’s up to you :slight_smile:

You can disable the Italic in Font Manager in theme options, but that will only disable the italic styling and not the font request. Italic is automatically added since it can be used anywhere, it’s like having a system font but you can freely select italic or not. But what if the italic isn’t included? But you use to choose the italic styling right in the text editor?

Imagine if user’s contents have italic contents as his preference, but later he decided to redesign it. He switches to different fonts and the italics are gone. Hence in this setup, Italic was just made part of the system for continuity of styling across different fonts since browser always assume that a text has the italic version of it.

BUT, if you wish to disable google fonts completely then please add this code to your child theme’s functions.php

add_filter( 'cs_load_google_fonts', '__return_false' );

Thanks!

Perfect, thanks Rad!

Yeah, it makes sense to add the italics by default. It’s just that I know I will never use certain fonts in italic and am looking to reduce page size along with some other optimizations.

All the best, Freek

You are most welcome. :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.