Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOUC when using typeface- package #9760

Closed
zvinless opened this issue Nov 6, 2018 · 2 comments
Closed

FOUC when using typeface- package #9760

zvinless opened this issue Nov 6, 2018 · 2 comments
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@zvinless
Copy link
Contributor

zvinless commented Nov 6, 2018

Description

There is a quick flicker of unstyled content on initial page load when using a font from a typeface package.

I'm guessing it's this issue.

Steps to reproduce

  1. Install a typeface package, e.g. yarn add typeface-pattaya
  2. Use it as a font in some css
  3. Import the font and css in a page
  4. Start gatsby dev server
  5. Visit the dev server address in Chrome
  6. Observe quick flicker of unstyled text before the styled font appears
  7. Refresh a bunch and observe the flicker each time

It's also visible in a deployed production build (can be hard to see sometimes but definitely happening):
Demo repo
Demo site

Expected result

No default font should be visible at all before the styled font

Actual result

The default font is visible in place of the styled font for a split second

Environment

  System:
    OS: macOS 10.14
    CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 11.1.0 - /usr/local/bin/node
    Yarn: 1.12.1 - /usr/local/bin/yarn
    npm: 6.4.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 70.0.3538.77
    Firefox: 63.0.1
    Safari: 12.0
  npmPackages:
    gatsby: ^2.0.33 => 2.0.40 
@kakadiadarpan kakadiadarpan added type: bug An issue or pull request relating to a bug in Gatsby status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. status: inkteam to review labels Nov 7, 2018
@LekoArts LekoArts added type: question or discussion Issue discussing or asking a question about Gatsby and removed status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. status: inkteam to review type: bug An issue or pull request relating to a bug in Gatsby labels Nov 7, 2018
@LekoArts
Copy link
Contributor

LekoArts commented Nov 7, 2018

It’s working as expected. Using typefaces doesn’t mean that you won’t have FOUC out of the box. Moreover font-display: swap exactly does that. If you don’t want FOUC you have to preload your fonts.

@zvinless
Copy link
Contributor Author

zvinless commented Nov 7, 2018

@LekoArts thanks for the clarification!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

3 participants