You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-5Lines changed: 11 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Performant asynchronous font loading plugin for Gatsby.
6
6
* Preloads the files & preconnects to the URL
7
7
* Loads fonts asynchronously to avoid render blocking
8
8
* Implemented with [fast loading snippets](https://csswizardry.com/2020/05/the-fastest-google-fonts/)
9
-
* Loading status listener for avoiding FOUT & FOUC
9
+
* Loading status listener for avoiding FOUT
10
10
* Small size & minimal footprint
11
11
12
12
## Install
@@ -29,12 +29,18 @@ Add the following snippet to `gatsby-config.js` plugins array.
29
29
/* Plugin options */
30
30
options: {
31
31
32
-
/* Enable font loading listener to handle FOUC*/
32
+
/* Enable font loading listener to handle FOUT*/
33
33
enableListener:true,
34
34
35
35
/* Preconnect URL-s. This example is for Google Fonts */
36
36
preconnect: ["https://fonts.gstatic.com"],
37
37
38
+
/* Font listener interval (in ms). Default is 300ms. Recommended: >=300ms */
39
+
interval:300,
40
+
41
+
/* Font listener timeout value (in ms). Default is 30s (30000ms). Listener will no longer check for loaded fonts after timeout, fonts will still be loaded and displayed, but without handling FOUT. */
42
+
timeout:30000,
43
+
38
44
/* Self-hosted fonts config. Add font files and font CSS files to "static" folder */
39
45
custom: [
40
46
{
@@ -57,9 +63,9 @@ Add the following snippet to `gatsby-config.js` plugins array.
57
63
}
58
64
```
59
65
60
-
## Handling FOUC with Font loading listener
66
+
## Handling FOUT with Font loading listener
61
67
62
-
When loading fonts asynchronously, Flash Of Unstyled Content (FOUC) might happen because fonts load few moments later after page is displayed to the user.
68
+
When loading fonts asynchronously, Flash Of Unstyled Text (FOUT) might happen because fonts load few moments later after page is displayed to the user.
63
69
64
70
To avoid this, we can use CSS to style the fallback font to closely match the font size, line height and letter spacing of the main font that is being loaded.
65
71
@@ -75,7 +81,7 @@ Here is the example of how `body` element will look like after all fonts are bei
0 commit comments