4

The Google fonts is now being blocked/heavily throttled in China, and our website is very slow now.

We want to way to handle the failure situation instead of letting our user to wait. It is okay to fail back to use the system font when Google failed to delivery, so, how to fix that if we use the code below?

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

Will change to use the JS API fix that?

WebFontConfig = {
    google: { families: [ 'Open+Sans::latin' ] }   };   

   (function() {
    var wf = document.createElement('script');
    wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
      '://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);   })();
Howard
  • 19,215
  • 35
  • 112
  • 184

4 Answers4

3

Although I can't say if this would work in China, but elsewhere, this issue could be solved by using https instead of http in the link URL.

karolus
  • 912
  • 7
  • 13
1
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>

Use https:

<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>

It works fine.

Floern
  • 33,559
  • 24
  • 104
  • 119
suraj
  • 326
  • 4
  • 6
0

Have you considered downloading and hosting the font yourself on your site? How to host google web fonts on my own server? This way it would all come from you site so in theory it would load just as fast or as slow as your site loads.

Community
  • 1
  • 1
obi1kenobi2
  • 43
  • 1
  • 8
  • 1
    In the common case when Google Fonts is working correctly, it's likely to be faster than the average host users of fonts might be using. – Michael Mior Jun 10 '16 at 16:01
0

As of August 2016 this has been fixed. See my answer here. Google is now serving the fonts from servers in China.

Community
  • 1
  • 1
mhatch
  • 4,441
  • 6
  • 36
  • 62