03Apr

Google fonts render blocking – page speed

Avoid render blocking font when you use google fonts. Here is a short bit of javascript to load your google font asynchronously.

Load your Google fonts asynchronously

You can do that by using Google’s Web Font Loader. Simply place the following code below in your footer.

<script type="text/javascript">
  WebFontConfig = {
    google: { families: [ 'Lato:400,400i,700|Roboto+Slab:400,700' ] }
  };
  (function() {
    var wf = document.createElement('script');
    wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
    wf.type = 'text/javascript';
    wf.async = 'true';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(wf, s);
  })(); </script>

Hope that help. This is good for speed and so it’s a bonus for your SEO ;)

Leave a Reply