Load Google Fonts without blocking rendering
Load Google Fonts without blocking rendering with preconnect, a print media swap and display=swap, so the text shows in a fallback font first.
A stylesheet in the head blocks rendering until it arrives. For Google Fonts you can keep the text visible by combining display=swap with a stylesheet that loads without blocking.
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap"
media="print" id="gf">const sheet = document.querySelector('#gf');
function enable() {
sheet.media = 'all';
console.log('font stylesheet applied');
}
if (sheet.sheet) enable();
else sheet.addEventListener('load', enable);font stylesheet appliedA stylesheet with media="print" downloads at low priority and does not block rendering for screens. When it finishes, switching media to all applies it. display=swap in the URL makes each @font-face use font-display: swap, so text appears at once in the fallback and swaps when the font is ready. The preconnect links start the TLS handshake early. The crossorigin is needed on the font host.
This relies on JavaScript, so add a <noscript> copy of the normal link. Self-hosting the font files removes the third-party request entirely, and a fallback with matched metrics reduces the shift when the swap happens. See font-display.