[Support request] The Fastest Google Fonts – functions.php

Home Forums Support [Support request] The Fastest Google Fonts – functions.php

Home Forums Support The Fastest Google Fonts – functions.php

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1543282
    Julian

    Is there a way to use this technique for loading google fonts from google cdn in the functions.php?

    https://css-tricks.com/the-fastest-google-fonts/

    #1543317
    Elvin
    Staff
    Customer Support

    Hi,

    To clarify: do you need these codes added to your site’s <head>?

    You can do that by either placing these <link> markups on a Hook Element that is hooked to wp_head.
    https://docs.generatepress.com/article/hooks-element-overview/

    or,

    place this PHP snippet on your child theme’s functions.php.

    add_action( 'wp_head', function () { ?>
    // your code here. presumably the <link> ones.
    <?php } );
    #1546440
    Julian

    I was more looking for an “out of the box” solution in form of a functions.php for externally hosted google webfonts. Soemthing that “hooks into” when a google webfont is selected in the customizer. I know how to do it manually.

    #1547383
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    GeneratePress will preconnect Google fonts automatically.

    It doesn’t preload at the moment – we’ll look into that during our Typography rewrite (scheduled for 3.1.0).

    #1547652
    Julian

    Awesome Tom, the workaround which I liked above improves the loading and pagespeed insights as well. Have a look at it ๐Ÿ™‚

    #1550195
    Tom
    Lead Developer
    Lead Developer

    Added that link to our Typography re-write task ๐Ÿ™‚

    Thanks!

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.