(function(h,o,t,j,a,r){ h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)}; h._hjSettings={hjid:3011767,hjsv:6}; a=o.getElementsByTagName('head')[0]; r=o.createElement('script');r.defer=1; r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv; a.appendChild(r); })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');

Font Optimization Guide: Web-Safe Fonts, Subsettings

Published on April 24, 2025
Last Updated on July 1, 2025

Written by

Morgan Frank - Specialist in Page Speed

Fonts play a crucial role in your website’s design and branding, but they can also significantly impact page speed. Large font files, poorly chosen font loading strategies, and unnecessary font variations can all lead to slower rendering and a poorer user experience.

This guide covers key font optimization techniques: choosing web-safe fonts, subsetting, and implementing effective font loading strategies.

Before we delve into specifics, let’s highlight the crucial takeaways:

 

Key Takeaways

1. Web-Safe Fonts are a Fallback, Not a Primary Strategy:

  • What they are: Fonts that are pre-installed on most operating systems (e.g., Arial, Times New Roman, Verdana).
  • Why they matter: They ensure that your text will be displayed even if your custom web fonts fail to load. However, relying solely on web-safe fonts severely limits your design options.
  • How to use them: Always specify web-safe fonts as fallbacks in your CSS font-family declarations.

2. Subsetting Reduces Font File Size:

  • What it is: Removing unused characters (glyphs) from a font file. Most fonts contain many characters you’ll never use (e.g., characters from different languages).
  • Why it matters: Smaller font files download faster, improving page speed.
  • How to do it: Use tools like Font Squirrel’s Webfont Generator or the glyphhanger command-line tool to create subsets.

3. font-display Controls Font Loading Behavior:

  • What it is: A CSS property that tells the browser how to handle font loading and rendering. It’s the most important tool for controlling the user experience during font loading.
  • Why it matters: It prevents the “Flash of Invisible Text” (FOIT) and minimizes the “Flash of Unstyled Text” (FOUT), improving perceived performance.
  • How to use it: Use font-display: swap; for most cases. Consider font-display: optional; for less critical fonts.

4. Preloading Critical Fonts:

  • What it is: Telling the browser to download specific font files early in the loading process.
  • Why it matters: It ensures that critical fonts are available as soon as possible, reducing the chance of layout shifts (CLS) and improving rendering speed.
  • How to do it: Use the <link rel=”preload”>   tag in your HTML <head>.

5. Host Fonts Locally (If Possible):

  • What does it mean: Rather than using fonts from CDN, host it on your server.
  • Why it matters: Reduces external requests, Potentially faster loading.
Font Optimization 1

1. Choosing Web-Safe Fonts (as Fallbacks)

Web-safe fonts are fonts that are pre-installed on a large percentage of operating systems. This means that if a user’s browser can’t download your custom web fonts (for whatever reason), the text will still be displayed using a web-safe font.

Common Web-Safe Fonts:

  • Arial
  • Verdana
  • Helvetica (often a fallback for Arial)
  • Times New Roman
  • Georgia
  • Courier New
  • Trebuchet MS
  • Tahoma

Using Web-Safe Fonts in CSS:

You should always specify web-safe fonts as fallbacks in your CSS font-family declarations. This is done by listing the fonts in order of preference, separated by commas.

 body {
 font-family: "MyCustomFont", Arial, sans-serif;
 }

In this example:

  1. The browser will try to load and display “MyCustomFont” (your custom web font).
  2. If “MyCustomFont” fails to load, the browser will try to use Arial.
  3. If Arial is not available, the browser will use the default sans-serif font for the system.

Important: Web-safe fonts are fallbacks. They are not a primary font strategy. Relying solely on web-safe fonts severely limits your design options and can make your website look generic.

2. Subsetting: Reducing Font File Size

Font files, especially those for web fonts, can be surprisingly large. This is because they often contain hundreds or even thousands of characters (glyphs) – letters, numbers, symbols, and characters from different languages. In most cases, you’ll only use a small fraction of these characters on your website.

Subsetting is the process of creating a smaller version of a font file that only includes the characters you actually need.

Benefits of Subsetting:

  • Significantly Reduced File Size: Subsetting can often reduce font file sizes by 50-90% or more.
  • Faster Download Times: Smaller files download much faster, improving page speed.
  • Improved Performance: The browser has less data to process, leading to faster rendering.

Tools for Subsetting:

  • Font Squirrel Webfont Generator: A popular online tool that allows you to subset fonts and generate the necessary CSS.
  • Glyphhanger: A command-line tool (developed by Filament Group) that provides more advanced subsetting options.
  • Transfonter: Another online tool for converting and subsetting fonts.
Font Optimization 2

How to Subset:

1. Identify the characters you need: Analyze your website’s content and determine which characters are actually used. This might include:

  • Basic Latin characters (AZ, a-z, 09)
  • Punctuation marks
  • Specific symbols
  • Characters from other languages (if your website is multilingual)

2. Use a subsetting tool: Use one of the tools mentioned above to create a subset of your font file containing only the necessary characters.

3. Update your CSS: Update your CSS @font-face declarations to point to the subsetted font files.

3. Font Loading Strategies: font-display and Preloading

How you load your fonts is just as important as choosing and subsetting them. Poor font loading strategies can lead to:

  • Flash of Invisible Text (FOIT): The text is initially invisible until the web font loads.
  • Flash of Unstyled Text (FOUT): The text is initially displayed using a fallback font, and then “flashes” to the web font once it loads. This can cause layout shifts (CLS).

The font-display CSS property is your primary tool for controlling font loading behavior.

font-display

The font-display property tells the browser how to handle the display of text while a web font is loading. It accepts the following values:

  • auto: (Default) The font loading behavior is determined by the browser. This usually results in FOIT.
  • block: The browser hides the text for a short period (“block period”). If the font loads within this period, it’s displayed. If not, the fallback font is used. After the block period, if the font is still not loaded, it will cause a FOUT.
  • swap: The browser displays the text immediately using a fallback font. Once the web font loads, it “swaps” the fallback font for the web font. This prevents FOIT, but it can cause FOUT and potentially CLS. This is generally the recommended option for most cases.
  • fallback: Similar to swap, but the browser gives the web font a very short time to load (around 100ms). If it doesn’t load within that time, the fallback font is used, and the web font is not swapped in, even if it loads later.
  • optional: The browser displays the text immediately using a fallback font. The web font is only used if it’s already cached or can be downloaded extremely quickly (within a few milliseconds). Otherwise, the fallback font is used for the entire page view. This is a good option for less critical fonts where using the fallback font is acceptable.
 @font-face {
  font-family: "MyCustomFont";
  src: url("my-font.woff2") format("woff2"),
     url("my-font.woff") format("woff");
  font-display: swap; /* Use the 'swap' value */
 }

Recommendation:

  • Use font-display: swap; for most of your web fonts. This provides the best balance between preventing FOIT and ensuring the web font is eventually displayed.
  • Consider font-display: optional; for less critical fonts, where using the fallback font is acceptable.
Font Optimization 3

Preloading Fonts

Preloading tells the browser to download specific font files early in the loading process, before they are actually needed by the CSS. This can significantly improve rendering speed, especially for critical fonts (those used for above-the-fold content).

You preload fonts using the <link rel=”preload”> tag in the <head> of your HTML:

<head>
 <link rel="preload" href="my-font.woff2" as="font" type="font/woff2" 
crossorigin>
</head>
  • href: The path to the font file.
  • as=”font”: Specifies that the resource being preloaded is a font.
  • type: Specifies the MIME type of the font file (e.g., font/woff2, font/woff, font/ttf).
  • crossorigin: This attribute is required for fonts, as they are subject to Cross-Origin Resource Sharing (CORS) policies.

Best Practices for Preloading:

  • Only preload critical fonts: Don’t preload every font on your website. Focus on the fonts that are used for above-the-fold content.
  • Use the correct type attribute: Make sure the type attribute matches the actual font file format.
  • Test: Test your implementation to ensure that preloading is actually improving performance.
Font Optimization 4

Host Locally

Loading fonts from a third-party service, like Google Fonts, can introduce additional network requests and potential delays. Host it on your server or CDN.

Conclusion

Optimizing your fonts is a critical, yet often overlooked, aspect of website performance. By choosing web-safe fallbacks, subsetting your fonts, using font display: swap; (or optional in some cases), and preloading critical fonts, you can significantly reduce font file sizes, improve rendering speed, and create a better user experience. These techniques work together to ensure that your fonts are loaded efficiently and don’t negatively impact your website’s performance. Remember to test your changes and monitor your page speed metrics to ensure your optimizations are effective.

Shakeeb Sadikeen

The expert that experts learn from

About Author

Determined to change that, he built RapidLoad — a smart, AI-driven tool that empowers site owners to dramatically improve speed scores, enhance user experience, and meet Google’s Core Web Vitals without needing to touch a single line of code.
Connect with Shakeeb Sadikeen

Table of content