BLOG-92 Fix improve google font loading efficiency #111
@ -18,9 +18,18 @@
|
|||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
<link
|
<link
|
||||||
|
id="google-fonts"
|
||||||
href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono&family=Noto+Sans+TC:wght@100..900&display=swap"
|
href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono&family=Noto+Sans+TC:wght@100..900&display=swap"
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
|
media="print"
|
||||||
/>
|
/>
|
||||||
|
<noscript>
|
||||||
|
<link
|
||||||
|
href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono&family=Noto+Sans+TC:wght@100..900&display=swap"
|
||||||
|
rel="stylesheet"
|
||||||
|
/>
|
||||||
|
</noscript>
|
||||||
|
<script src="%sveltekit.assets%/js/font-loader.js" defer></script>
|
||||||
%sveltekit.head%
|
%sveltekit.head%
|
||||||
</head>
|
</head>
|
||||||
<body data-sveltekit-preload-data="hover" class="antialiased">
|
<body data-sveltekit-preload-data="hover" class="antialiased">
|
||||||
|
7
frontend/static/js/font-loader.js
Normal file
7
frontend/static/js/font-loader.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// Defer loading of fonts to improve performance
|
||||||
|
window.addEventListener('load', function() {
|
||||||
|
const fontLink = document.getElementById('google-fonts');
|
||||||
|
if (fontLink) {
|
||||||
|
fontLink.media = 'all';
|
||||||
|
}
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user