Skip to content

Commit

Permalink
Make font-display optional instead of swap. The CLS impact of swap is…
Browse files Browse the repository at this point in the history
… too bad
  • Loading branch information
cramforce committed Jan 28, 2021
1 parent bf130e8 commit bff0ad7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ npm run build
#### Fonts

- Serves fonts from same origin.
- Makes fonts `display:swap`.
- Makes fonts `display:optional`.

#### Analytics

Expand Down
7 changes: 5 additions & 2 deletions _11ty/optimize-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const csso = require("csso");

/**
* Inlines the CSS.
* Makes font display display-swap
* Makes font display display-optional
* Minifies and optimizes the JS
* Optimizes HTML
* Optimizes AMP
Expand All @@ -49,7 +49,10 @@ const purifyCss = async (rawContent, outputPath) => {
encoding: "utf-8",
});

before = before.replace(/@font-face {/g, "@font-face {font-display:swap;");
before = before.replace(
/@font-face {/g,
"@font-face {font-display:optional;"
);

const purged = await new PurgeCSS().purge({
content: [
Expand Down

0 comments on commit bff0ad7

Please sign in to comment.