Monday, June 15, 2015

Web Performance Optimization: Limit Web Font size

After using images for years, I switched to using web fonts a few years ago and never looked back. Thanks to web fonts you can use (almost)any font combination you want in your website without rendering it to an image first and embedding it into your page. You can now easily change the font of your website without replacing all the images. I don’t miss the old times…

The only disadvantage that web fonts have is that they add some overhead to your website as the font should be loaded first. However if you are using Google Fonts than there are some neat tricks to limit the extra cost.

Trick 1 – Specify the exact text

If you only need some specific letters, you can specify them:

http://fonts.googleapis.com/css?family=Open+Sans&text=Test

Trick 2 – Specify a subset

Another thing you can do, is limit the character set that you use:

http://fonts.googleapis.com/css?family=Open+Sans&subset=latin

Trick 3 – Specify multipe fonts

If you use multiple web fonts in your website, you can download them all in one request:

http://fonts.googleapis.com/css?family=Open+Sans|Roboto

1 comment:

pencilandengine.com said...

That's good to know, cut one of my page loads down by 80% or so!