BLOG-92 feat: defer font loading to improve performance
This commit is contained in:
parent
48005d1f52
commit
1e1bae0812
@ -18,10 +18,10 @@
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
id="google-fonts"
|
||||
href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono&family=Noto+Sans+TC:wght@100..900&display=swap"
|
||||
rel="stylesheet"
|
||||
media="print"
|
||||
onload="this.media='all'"
|
||||
/>
|
||||
<noscript>
|
||||
<link
|
||||
@ -29,6 +29,7 @@
|
||||
rel="stylesheet"
|
||||
/>
|
||||
</noscript>
|
||||
<script src="%sveltekit.assets%/js/font-loader.js" defer></script>
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<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