Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Commit

Permalink
improve font defer
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Dec 31, 2021
1 parent c5f5955 commit 4207407
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 0 additions & 1 deletion client/src/index.html
Expand Up @@ -4,7 +4,6 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CAwitter</title>
<link rel="stylesheet" href="/fonts/webfont.css" media="print" onload="this.media='all'" />
</head>
<body>
<div id="app"></div>
Expand Down
7 changes: 7 additions & 0 deletions client/src/index.jsx
Expand Up @@ -10,3 +10,10 @@ ReactDOM.render(
</BrowserRouter>,
document.getElementById('app'),
);

requestIdleCallback(() => {
const $font = document.createElement('link')
$font.rel = 'stylesheet'
$font.href = '/fonts/webfont.css'
document.head.append($font)
})

0 comments on commit 4207407

Please sign in to comment.