Browsers that support preload and prefetch hints will start downloading web fonts as soon as they have seen the hint in the HTML file and no longer need to wait for the CSS. Using the preload hints will have a dramatic impact on web font performance and initial page load. They also tell the browser that this is a font, so it can appropriately prioritise it in its resource queue. In the above example, the rel="preload" as="font" attributes will ask the browser to start downloading the required resource as soon as possible. This is because fonts are expected to be fetched anonymously by the browser, and the preload request is only made anonymous by using the this attribute. Note that the use of crossorigin here is important without this attribute, the preloaded font is ignored by the browser, and a new fetch takes place. When using custom fonts you should tell the browser to preload them using the appropriate rel="" tag and attributes: These are the only two file types you should use because they are compressed in the gzip format by default (so they are very small), are optimised for the web, and are fully supported by IE 9+ and all other evergreen browsers. There are many font formats that can be used on the web, but only two formats are really needed if you don’t have to support Internet Explorer (IE) 8 or lower: woff and woff2. Let’s break down these points one at a time. Avoid invisible text during font loading.There are just four steps to consider when loading a custom web font:
It’s time to break this loop and start doing the right thing in 2019. I see many developers ignoring these issues or perhaps making the same errors over and over just because “they have always done so”, but as web developers we need to be able to adapt in a constantly changing environment. This causes a lot of problems for page loading like performance issues, slow loading time, blocked rendering and swapped fonts during navigation. Custom web fonts are used everywhere around the world, but many (oh so many) sites load them improperly.