- Self-hosting is significantly faster. Loading a typeface from Google Fonts or other hosted font service adds an extra (blocking) network request. In my testing, I’ve found replacing Google Fonts with a self-hosted font can improve a site’s speedindex by ~300 miliseconds on desktop and 1+ seconds on 3g. This is a big deal.
- Your fonts load offline. It’s annoying to start working on a web project on the train or airplane and see your interface screwed up because you can’t access Google fonts. I remember once being in this situation and doing everything possible to avoid reloading a project as I knew I’d lose the fonts and be forced to stop working.
- Go beyond Google Fonts. Some of my favorite typefaces aren’t on Google Fonts like Clear Sans, Cooper Hewitt, and Aleo.
- All web(site|app) dependencies should be managed through NPM whenever possible. Tis the modern way.
Each typeface package ships with all the necessary font files and css to self-host an open source typeface.
All Google Fonts have been added as well as a small but growing list of other open source fonts. Open an issue if you want a font added!
Couldn’t be easier. This is how you’d add Open Sans.
npm install --save typeface-open-sans
Then in your app or site’s entry file.
And that’s it! You’re now self-hosting Open Sans!
It should take < 5 minutes to swap out Google Fonts.
Typeface assumes you’re using webpack with loaders setup for loading css and font files (you can use Typeface with other setups but webpack makes things really really simple). Assuming your webpack configuration is setup correctly you then just need to require the typeface in the entry file for your project.
If you’re not using webpack or equivalent tool that allows you to require css, then you’ll need to manually integrate the index.css and font files from the package into your build system.