December 20, 2013

4 Tips To Faster Loading Google Fonts

Load Google Fonts First Before CSS

Place the Google import code such that it loads first directly after the html HEAD tag, EVEN before loading the CSS file. This ensures the fonts load before the CSS so there isn’t any unexpected “jumping” of when the font finally loads. This is actually becoming very common in sites that I have seen recently.

Use Link Format

There are 3 ways in which you can load Google Fonts‚ @import, link rel and javascript. The link rel tag will allow you to place the code on the html and load it the fastest before the CSS file.

Here is an example:

http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>

@import code needs to be inserted into the CSS file, and although you may add it at top of the CSS file, you may still get a flash of unstyled text (FOUT) ‚ which results in a poor user experience as explained above.

Fewer Fonts

Do you really need 6 different font types for your site? Absolutely not. It is best to design with a maximum of two fonts ‚ one bold type for headlines and a high readability font for main body text. Obviously, the more fonts you choose to load from Google, the slower the page load, and surprisingly this can add up pretty quick.

Combine Your Font Codes

You can load multiple Google fonts with a single line of code. This means you do not need to have separate rows of code for each font you load. See the example below where I have combined the Open Sans and Fenix font.

http://fonts.googleapis.com/css?family=Open+Sans|F... rel='stylesheet' type='text/css'>

Conclusion

Like every other element in your website, keep it minimal. Try these tips out if you are loading fonts differently than what we have covered here and see if it makes a difference. Depending on the size of your site, it may not be easily noticed, this is where the ‘Network’ tab within Chrome’s inspect element feature shines. You will probably see a decrease somewhere in the ms, and believe me, every bit counts!

Paul Weinert
Author

Paul Weinert is our founder, managing principal and spirit animal. He’s one of those odd people you meet that was born in Portland, grew up here and still lives here for some reason. If you had two words to describe Paul after meeting him, we’d bet you’d use “charmingly quirky”.

Paul started GRAYBOX in February 2009, and for the first four years, GRAYBOX had a blend of a contract staffing firm and a traditional agency. GRAYBOX then hired our first employees in 2012 and has been growing ever since. Professionally, Paul has a background in internet business consulting, working especially with mid-market ecommerce, healthcare, and tech companies. He worked as a user experience designer, web developer and internet marketer. Nowadays, Paul serves as our company visionary, team mentor and head of executive leadership — Paul is extremely proud of the entire team and the company. He’s constantly humbled by the team’s awesomeness and the caring community that’s sprung up from his initial ideas.

Beyond GRAYBOX, Paul is married, has two young boys and lives in NE Portland. He’s also an active foster parent, mentors other local entrepreneurs, and volunteers on local non-profit boards. Businesswise, aside from GRAYBOX, Paul has started a few other businesses and is an active investor in the local startup scene.

For the sheer joy of it, let’s play 2 truths and a lie:

  1. Paul firmly believes that any activity would be better if on a boat.
  2. Other than this whole Internet thing, Paul has basically no other skills or expertise in anything.
  3. Paul is rare unicorn, actually born and raised in Portland.