Skip to content

Commit 4eb0e08

Browse files
authored
docs(themes): update Preloading Fonts section (#2837)
1 parent a04da4a commit 4eb0e08

File tree

1 file changed

+18
-14
lines changed
  • sites/skeleton.dev/src/routes/(inner)/docs/themes

1 file changed

+18
-14
lines changed

sites/skeleton.dev/src/routes/(inner)/docs/themes/+page.svelte

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ plugins: [
172172
</p>
173173
<CodeBlock language="html" code={`<html class="dark">`} />
174174
<p>
175-
Note that Skeleton also provides a <a class="anchor" href="/docs/dark-mode#via-selector" target="_blank">Lightswitch</a> utility if you wish
176-
toggle between light and dark modes.
175+
Note that Skeleton also provides a <a class="anchor" href="/docs/dark-mode#via-selector" target="_blank">Lightswitch</a> utility if you
176+
wish to toggle between light and dark modes.
177177
</p>
178178
</section>
179179

@@ -308,23 +308,27 @@ body {
308308
/>
309309
{/each}
310310
<!-- 5 -->
311-
<h3 class="h3" data-toc-ignore>5. Preloading Fonts.</h3>
311+
<h3 class="h3" data-toc-ignore>5. Handle Font Flickering.</h3>
312312
<p>
313-
To avoid your page flickering during hydration, consider preloading fonts within the <code class="code">head</code>
314-
tag in <code class="code">app.html</code>
313+
To avoid your page flickering during hydration, consider using the <code class="code">font-display</code> descriptor for the
314+
<code class="code">@font-face</code>
315+
at-rule that determines how a font face is displayed based on whether and when it is downloaded and ready to use.
316+
<br />
317+
<br />Replace your <code class="code">@font-face</code> at-rule with the following:
315318
</p>
316319
{#each activeFonts as f}
317320
<CodeBlock
318-
language="html"
321+
language="css"
319322
code={`
320-
<link
321-
rel="preload"
322-
href="%sveltekit.assets%/fonts/${f.file}"
323-
as="font"
324-
type="font/ttf"
325-
crossorigin
326-
/>
327-
`}
323+
@font-face {
324+
/* Reference name */
325+
font-family: '${f.name}';
326+
/* For multiple files use commas, ex: url(), url(), ... */
327+
src: url('/fonts/${f.file}');
328+
/* Gives the font face an extremely small block period and an infinite swap period. */
329+
font-display: swap;
330+
}
331+
`}
328332
/>
329333
{/each}
330334
{:else if tabsFontImport === 1}

0 commit comments

Comments
 (0)