P
P
Philip Gavrilov2018-06-05 21:29:07
css
Philip Gavrilov, 2018-06-05 21:29:07

How to prevent script execution before fonts are loaded?

There is a script that works with fonts on the site.
When the page is first loaded, they are executed even before the font is fully loaded via @font-face and there are many jambs.
You need to run the script only after downloading the font files. How?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Glebov, 2018-06-05
@Filgavrilov

document.fonts.load("bold 16px Lato", "b").then(function() {
    //
});

https://developer.mozilla.org/en-US/docs/Web/API/F...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question