question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How should we handle custom fonts?

See original GitHub issue

Hello šŸ‘‹

I’m a but stuck on deciding how we should handle our custom fonts.

At the moment, I’m bundling them within Radix itself. But it seems that in total we’ll have about 4 different font families. Bundling them as base64 will increase the bundle size quite a bit - I’m not sure this is a good idea.

Another option is instead of bundling the as base64, I can copy them over to the dist folder and load them in?

Oooor, have some sort of ā€œFont serverā€? We can then load the fonts in async, just like Google fonts.

What are your thoughts?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
StephenHaneycommented, Jul 2, 2019

Seems fine – and we’d just add instructions to add the fonts in our ā€œGetting Startedā€ page in the docs?

Not sure if increasing bundle size is a concern if they have to load the fonts either way. The decrease in bundle size is equal to the increase in the CDN http requests, right? And these fonts aren’t likely to be cached already like a Google font.

So I’d say we should do whatever supports flexibility and the best, smoothest font loading experience for the actual page viewer.

1reaction
TheSisbcommented, Jul 11, 2019

Just wanted to suggest not using base64. Browsers are smart and only download the font file (woff, etc) when some part of the page depends on it (an element on the page has css that sets that specific font family -> file). So you can theoretically define 10+ fonts, but if your page only uses a couple then only those ones get downloaded by the browser. By using base64 you force the download and increase page initialization time. Hosting fonts on a CDN is a great idea; I think of fonts as I would any known static asset.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best practices for fonts - web.dev
This article discusses performance best practices for fonts. There are a variety of ways in which web fonts impact performance:.
Read more >
The Easy Way to Add Fonts to Your Website (Including ...
In this article, I will walk you through the step-by-step process for adding any ... Find the custom font you want to use...
Read more >
Web fonts - Learn web development - MDN Web Docs - Mozilla
Make sure you have satisfied any licensing requirement if you are going to use this in a commercial and/or Web project. Ā· Go...
Read more >
The performance cost of custom web fonts, and how to solve it
Custom web fonts are an essential part of most web design, but they come at a performance cost. This post looks at addressing...
Read more >
How To Load and Use Custom Fonts with CSS | DigitalOcean
In this tutorial, you will try out examples of loading fonts onto your website. You will use the font stack, a rank ordering...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found