Black Friday! Get up to 25% off GP Premium! Learn more ➝

[Support request] Load Google Fonts Async

Home Forums Support [Support request] Load Google Fonts Async

Home Forums Support Load Google Fonts Async

  • This topic has 6 replies, 1 voice, and was last updated 1 year, 8 months ago by TheSalvadorDaliOfWebsites.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #365690

    Hi Tom,

    As you know most websites these days are using the useful Google web font library allowing you to import a huge library of fonts straight to your webpage so how we can you use the following code to load google fonts Async with GeneratePress.

    The google subset font is:,300,regular,500,600,700,800|Cairo:200,300,regular,600,700,900&subset=arabic

    The code snippet :
    <script type=”text/javascript”>
    WebFontConfig = {
    google: { families: [ ‘Changa’ ] }
    (function() {
    var wf = document.createElement(‘script’);
    wf.src = (‘https:’ == document.location.protocol ? ‘https’ : ‘http’) +
    wf.type = ‘text/javascript’;
    wf.async = ‘true’;
    var s = document.getElementsByTagName(‘script’)[0];
    s.parentNode.insertBefore(wf, s);
    // ]]></script>

    GeneratePress 1.3.48
    GP Premium 1.4.2

    I was wondering if there’s a way to load Google fonts asynchronously in GeneratePress. i.e. not in the head section of each page, so that the page will start to render before the fonts are loaded resulting in a better page speed rank.

    I’m looking at Google’s web font loader ( and came up with that code as they said to include at the page footer. But I’m not sure as to how to implement it in GeneratePress, as the theme itself outputs the code line in the head section.

    Lead Developer
    Lead Developer

    You would just tell GP not to load the fonts:

    add_action( 'after_setup_theme', 'tu_remove_google_font_call', 50 );
    function tu_remove_google_font_call() {
        remove_action( 'wp_enqueue_scripts','generate_enqueue_google_fonts', 0 );

    Then you would add your JS to the footer.


    Thanks Tom for the code, as many themes developer change the code to load Google fonts asynchronously
    can you add this in the Typography Add-on please.

    Lead Developer
    Lead Developer

    I’m definitely looking into it 🙂

    Ramesh Srinivasan

    +1 for the feature.

    : For now, will add the function you provided. Thank you!


    This is something I would like to see also.

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