• Enabling “Web Font Optimization” breaks Google fonts on the frontend for non-logged in users.

    The fonts are being included in functions.php with the following code:

    wp_enqueue_style( 'google-fonts', 'https://fonts.googleapis.com/css2?family=Merriweather:ital,wght@0,400;0,900;1,900&family=Open+Sans:wght@400;600;800&display=swap', array(), null, 'all');

    They work great with optimization disabled, but Merriweather fails to load for non-logged in users when optimization is enabled.

    Screenshots of Web Font Optimization enabled and disabled

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Dimitar Petrov

    (@demiro)

    Hello @joshf,

    I have tried to replicate the issue, but to no avail. Would you please provide us with detailed instruction on how we can reproduce the issue on our end? Please include all steps – adding the font(already included in your previous reply), defining the CSS and how you apply the font to the text.

    Best Regards,
    Dimitar Petrov

    Thread Starter Joshua Fredrickson

    (@joshf)

    Fonts enqueued per the above.

    CSS:

    h1, h2 {
        font-family: Merriweather,serif;
    }

    When signed in and Optimization enabled, the site properly enqueues the font:

    <link rel="stylesheet" id="google-fonts-css" href="https://fonts.googleapis.com/css2?family=Merriweather:ital,wght@0,400;0,900;1,900&family=Open+Sans:wght@400;600;800&display=swap" media="all">

    When logged out with Optimization enabled, the above line isn’t added to the head. The prefetch and dns-prefetch tags are there, but no link to the stylesheet.

    Plugin Support Plamen M

    (@plamenm)

    Hello @joshf ,

    This seems to be something specific to the theme that you are using. I installed several free themes that used Google Fonts but in them, the fonts were not added in the manner you mentioned.

    I tried to add the Google Font family Merriweather to the Twenty Twenty theme through your description, but the font is preserved regardless of whether the user is logged in or not, when Web Font Optimization is enabled.

    If you are using a free theme, please specify its name, so that we can try to recreate the issue.

    We look forward to your reply.

    Regards,
    Plamen.M
    Tech Support Team
    SiteGround.com

    Plugin Support Gergana Petrova

    (@gpetrova)

    Hello @joshf,

    Since we haven’t heard back from you for a few days, we will be marking the topic as Resolved.

    You will still be able to post new updates, in case additional assistance is needed.

    Best Regards,
    Gergana Petrova

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Web Font Optimization breaks font display’ is closed to new replies.