• Resolved michelgreenwood

    (@michelgreenwood)


    Hi Tom,

    I just noticed that when you specify a font in the customizer > typography, it creates a style sheet (generate-font-css I think) that combines all the font selections the user made in the customizer.

    That’s great, however, it seems that generate-font-css is requesting all the styles for each font family. Even if you specify only one font weight in the customizer, the style sheet is still calling for all the weights and italics.

    To compare, I cleared out the customizer font selections, which stopped the creation of generate-font-css. And I included a request for only the font families and weights I needed in the wp-head hook (with prefetch and preconnect). For my site, this cut the size of the font package in half.

    Just thinking it might be a nice improvement if the customizer only requested the styles/weights being used.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Theme Author Tom

    (@edge22)

    Hi there,

    I thought about this when I developed it, but what about when you’re using a font in your content and you decide you want to bold or italicize something?

    There are actually hidden inputs in the Customizer that get the variants for the font chosen which you can un-hide with some PHP:

    add_action('customize_controls_print_styles', 'tu_show_font_variants', 50);
    function tu_show_font_variants() {
    	?>
    	<style>
    		.customize-control-gp-hidden-input {display:block !important;}
    	</style>
    	<?php
    }

    Let me know if you need more info ??

    Thread Starter michelgreenwood

    (@michelgreenwood)

    Hi Tom,

    Thanks for the quick answer as always.

    That’s a good point. I guess without the extra font styles your bold and italic will fall back to the browser default. I suppose for the general user it’s best to have it the way you do.

    Thanks ??

    Theme Author Tom

    (@edge22)

    If you don’t think you’ll need all of the variants, then there’s definitely speed advantages to taking them out ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Customizer typography calls for all font styles’ is closed to new replies.