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

Optimize Google Fonts #119

Open
TedGoas opened this issue May 29, 2020 · 0 comments
Open

Optimize Google Fonts #119

TedGoas opened this issue May 29, 2020 · 0 comments
Assignees

Comments

@TedGoas
Copy link
Owner

TedGoas commented May 29, 2020

Harry Roberts wrote about how referencing Google Fonts from Google's CDN might be the best way to go. I've been self-hosting because I thought that's the best performance, however I've noticed FOUT on my own production site. If anyone's gone have my site chawed, it's me, and I'm still seeing the FOUT!

Let's test out Harry's idea. I've always liked the idea of referencing Google because you get extra font-hinting that makes type look better. Also, it's simple to implement and easy to maintain.

Harry recommends this at the end of his article:

<!--
  - 1. Preemptively warm up the fonts’ origin.
  -
  - 2. Initiate a high-priority, asynchronous fetch for the CSS file. Works in
  -    most modern browsers.
  -
  - 3. Initiate a low-priority, asynchronous fetch that gets applied to the page
  -    only after it’s arrived. Works in all browsers with JavaScript enabled.
  -
  - 4. In the unlikely event that a visitor has intentionally disabled
  -    JavaScript, fall back to the original method. The good news is that,
  -    although this is a render-blocking request, it can still make use of the
  -    preconnect which makes it marginally faster than the default.
  -->

<!-- [1] -->
<link rel="preconnect"
      href="https://fonts.gstatic.com"
      crossorigin />

<!-- [2] -->
<link rel="preload"
      as="style"
      href="$CSS&display=swap" />

<!-- [3] -->
<link rel="stylesheet"
      href="$CSS&display=swap"
      media="print" onload="this.media='all'" />

<!-- [4] -->
<noscript>
  <link rel="stylesheet"
        href="$CSS&display=swap" />
</noscript>
@TedGoas TedGoas self-assigned this May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant