PoolByte

Web fonts: Performance, font-display and licensing

· PoolByte Technology

Web fonts: Performance, font-display and licensing

Web fonts, which are an important part of corporate identity, affect the speed and visual stability of the site more than expected. Each font weight and style is a separate file; A site that uses four different weights and two italics may have to download six separate files before displaying the text. When the font loads slowly, the text may remain invisible for a while or may shift and shift the page layout once it loads.

In this article, we discuss practical steps to use web fonts both quickly and correctly in terms of licensing.

Count how many font files you use

The first step for web fonts is inventory. Open the Network tab in the browser's developer tools, limit the filter to fonts, and see how many files are downloaded when the page opens. Determine the weights actually used in the design; For most sites, one or two font families and two to three weights per family are sufficient.

Variable fonts are a good option if many weights are required. A single file can contain all weights from thin to thick and be smaller overall than multiple individual files.

Use WOFF2 format

WOFF2 is a compressed font format designed for the web and is supported by almost all current browsers. Use WOFF2 versions instead of serving TTF or OTF files directly. If very old browser support is not required, you do not need to add additional formats.

Create subsets without forgetting Turkish characters

A font file can contain thousands of characters; your site uses only some of them. Creating a subset makes the file smaller by removing unused characters. The point to note here is Turkish characters: if you use only the basic Latin subset, letters such as ğ, ş, ı, İ will be displayed in another font and the text will appear garbled. For Turkish, make sure Latin Extended characters are included in the subset.

If your site also uses a different writing system, such as Arabic, a separate font and subset is required for that language. With the definition unicode-range you can have the browser only download the file for the kerning actually used on the page.

Keep text visible with font-display

The font-display property determines what the browser does until the font is loaded. The value swap immediately displays the text with the substitute font and replaces it when the web font is loaded; The user starts reading the content without waiting. optional, on the other hand, if the font does not arrive very soon, continues with the spare font for that page display and prevents slippage caused by the change.

@font-face {
  font-family: "Kurumsal Sans";
  src: url("/fonts/kurumsal-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

To reduce drift that occurs when changing fonts, choose the replacement font close to the dimensions of the web font or match its dimensions to descriptions such as size-adjust. These shifts affect the CLS value in Core Web Vitals; details are in our Core Web Vitals guide.

Preload critical font only

Requesting the font of the title and body text that appears immediately when the page is opened in advance with preload will ensure that the text appears with the correct font sooner. However, preloading every font causes the browser to delay more important resources. Limit yourself to one or two files and don't forget to add the crossorigin attribute.

<link rel="preload" href="/fonts/kurumsal-sans.woff2" as="font" type="font/woff2" crossorigin>

Consider hosting on your own server

It's easy to install web fonts from a third-party service; however, it requires the browser to establish a connection to a separate server, and information such as the user's IP address is transmitted to that service. Serving fonts from your own domain eliminates this additional connection, lets you set your own cache times, and reduces the sharing of personal data with third parties. We have discussed the personal data dimension in our KVKK compliant website guide.

Give font files long cache time; these files rarely change. You can change the filename when it changes so that browsers pick up the new version.

Check license

Just because you have the right to use a font on your computer does not mean you can use it on your website. Commercial fonts are often licensed separately for desktop, web, and app; web licenses are sometimes limited to monthly views. Check that each font you use is authorized for use on the web and that you keep the license document.

Most of the fonts in Google Fonts are distributed under the SIL Open Font License. This license allows fonts to be used on websites, hosted on your own server, and created in subsets; However, it is a good habit to read the terms in the license text.

Frequently asked questions

Is using system fonts enough?

The lightest option in terms of speed is system fonts that are already installed on the device. If your brand identity does not require a specific font, a well-chosen system font stack will deliver a result that is both fast and readable.

Do I need a separate font for Arabic content?

Yes. Most fonts designed for Latin letters do not contain Arabic characters. For Arabic content, choose a font that supports this writing system and ensure it loads only on Arabic pages.

Official sources