Blocking loading of google fonts

All WYSIWYG Web Builder support issues that are not covered in the forums below.
Forum rules
IMPORTANT NOTE!!

DO YOU HAVE A QUESTION OR PROBLEM AND WANT QUICK HELP?
THEN PLEASE SHARE A "DEMO" PROJECT.



PLEASE READ THE FORUM RULES BEFORE YOU POST:
http://www.wysiwygwebbuilder.com/forum/viewtopic.php?f=12&t=1901

MUST READ:
http://www.wysiwygwebbuilder.com/getting_started.html
WYSIWYG Web Builder FAQ
Post Reply
Jae
 
 
Posts: 7
Joined: Tue Dec 20, 2022 2:03 am

Blocking loading of google fonts

Post by Jae »

I'm creating a new site using some google fonts. I have followed all instructions I can find but cannot get the font to stay hidden until the page is rendered - I get the "default' fonts flicker for a second.

I have added the fonts through Tools|Options|Fonts|Google Fonts and selected the host google fonts locally option (that part works - the woff files get uploaded as expected).

I have added the below to each page, "Between <head></head> tags

Code: Select all

<style>
@font-face {
    font-display: block !important;
}
</style>
No go.

What am I doing wrong?
Jae
 
 
Posts: 7
Joined: Tue Dec 20, 2022 2:03 am

Re: Blocking loading of google fonts

Post by Jae »

UPDATE: I added the below to the HEAD section of the SITE HTML. Seems to work..

Code: Select all

<style>
html.fonts-loading body {
    visibility: hidden;
    opacity: 0;
}

html.fonts-loaded body {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.15s ease-in;
}
</style>

<script>
document.documentElement.classList.add('fonts-loading');

window.addEventListener('load', function () {

    if (document.fonts) {
        Promise.all([
            document.fonts.load('16px "League Gothic"'),
            document.fonts.load('16px "DM Serif Display"'),
            document.fonts.load('16px "Inter"')
        ]).then(showPage).catch(showPage);
    } else {
        showPage();
    }

    // Safety net — never leave the page hidden
    setTimeout(showPage, 3000);

    function showPage() {
        document.documentElement.classList.remove('fonts-loading');
        document.documentElement.classList.add('fonts-loaded');
    }
});
</script>
User avatar
AliGW
 
 
Posts: 798
Joined: Thu Dec 19, 2024 3:41 pm

Re: Blocking loading of google fonts

Post by AliGW »

Strange - I haven't had to add any custom code and Google Fonts work fine without any of the flickering you mention.
Ali
Retired, but still loving to learn & very busy.
https://alisongwright.me.uk
Novice with WWB, but was an avid user of Serif WebPlus before.
Fairly expert at Microsoft Excel (but not VBA) & Affinity by Canva (for page layout).
Post Reply