Home » Blogs » Ensure text remains visible during webfont load in Shopify

Ensure Text Remains Visible During Webfont Load in Shopify

February 9, 2024 | 5 min read

Frustrated by invisible text during font loading in your Shopify store? You’re not alone. Thankfully, expert solutions exist! This guide, crafted by our software development team, empowers you to conquer this challenge and deliver a seamless user experience with custom webfonts.

1. Identification Webfonts Load

Tools like GT metrix, lighthouse, Page speed insights

Identification-Webfonts-load
web-font-mobile-view

The Solution: Embrace font-display: swap

The simplest solution is to leverage the font-display: swap CSS property. This instructs browsers to temporarily display a system font while the custom font loads, ensuring continuous text visibility.

Understanding @font-face

At the heart of webfont implementation lies the @font-face CSS rule. This rule defines the custom font, specifying variations like .woff2, .woff, and .ttf files. Here’s a simplified example:

2. What is @font-face?

A @font-face is a simple CSS rule through which you can apply a custom font to a text. It has extensions like woff2, woff, ttf, etc.
For example, a @font-face code will look like this-
You can easily fix this issue

Css Property:- font-display: swap;

Before

@font-face {
font-family: 'Pacifico';
font-style: normal;
font-weight: 400;
src: local('Pacifico Regular'),local('Pacifico-Regular'),
url(https://fonts.gstatic.com/s/pacifico/v12/FwZY7-Qmy14u9lezJ-6H
6MmBp0u-.woff2) format('woff2');
}

After

@font-face {
font-family: 'Pacifico';
font-style: normal;
font-weight: 400;
src: local('Pacifico Regular'),local('Pacifico-Regular'),
url(https://fonts.gstatic.com/s/pacifico/v12/FwZY7-Qmy14u9lezJ-6H 6MmBp0u-.woff2)
format('woff2');
Font-display: swap;
}

3. Leveraging Google Fonts

While Google Fonts doesn’t natively include font-display: swap, they offer a workaround. Simply add &display=swap to the Google Fonts URL parameter to achieve the desired effect.

Example

Before

<link href="https://fonts.googleapis,.com/css?family=Roboto:400,700"rel="stylesheet">

After

<link href="https://fonts.googleapis.com/css?family=Roboto:400,700&display=swap"rel="stylesheet">

Benefits of Mastering Webfont Loading

  • Enhanced User Experience: Eliminate distracting invisible text, fostering a professional and polished browsing experience.
  • Improved Conversion Rates: Smooth font loading keeps users engaged, promoting interaction and purchase decisions.
  • Boost SEO: Search engines favor fast-loading websites, potentially elevating your search ranking.

In conclusion, mastering webfont loading is an essential step towards a polished and high-performing Shopify store. By implementing the font-display: swap property and leveraging Google Fonts’ workaround, you can ensure continuous text visibility and eliminate jarring invisible text experiences. Remember, a positive user experience is paramount for conversions and SEO success. Embrace these expert techniques today and unlock the full potential of custom webfonts in your Shopify store!

Embrace expert techniques and conquer invisible text during webfont loading! Deliver a superior Shopify experience and watch your brand flourish.

Looking For Expert Shopify Speed Optimization And Other Services Get In Touch

Leave A Comment