Search code examples
cssfontsfont-face

Wait for fonts to load before rendering web page


I'm using @font-face to embed fonts in my website. First the text renders as the system default, and then (once the font file has loaded presumably) the correct font renders a fraction of a second later. Is there a way to minimise/get rid of this delay, by delaying the page rendering until after fonts have loaded or similar.


Solution

  • This is down to how the browser behaves.

    First off where is your @font declared? Is it inline to your HTML, declared in a CSS sheet on the page, or (hopefully) declared in an external CSS sheet?

    If it is not in an external sheet, try moving it to one (this is better practice anyway usually).

    If this doesn't help, you need to ask yourself is the fraction of a second difference really significantly detrimental to the user experience? If it is, then consider JavaScript, there are a few things you might be able to do, redirects, pauses etc, but these might actually be worse than the original problem. Worse for users, and worse to maintain.

    This link might help:

    http://paulirish.com/2009/fighting-the-font-face-fout/