Fix ‘Google Fonts Not Working in China’ Issue

Fix ‘Google Fonts Not Working in China’ Issue

Hello friends today we gonna learn about Fix ‘Google Fonts Not Working in China’ Issue. So read this article, Fix ‘Google Fonts Not Working in China’ Issue step by step so you may understand it in a better way. If you have query related to same article you may contact us. So Lets begin:

Guide: Fix ‘Google Fonts Not Working in China’ Issue

The reason we use Google API to serve libraries like jQuery and Web Fonts is that it is served quickly through Google’s reliable infrastructures. It is used almost everywhere, and so often that some users have already saved the cache in their browser, making the libraries load even faster.

Unfortunately, that is not the case in China. The Chinese government has closed access to many of Google’s services, including the Google API. Chances are, your website can seem partially broken in China because the jQuery and web fonts hosted in Google are not accessible.

In this post we are going to see how to bypass China’s ‘digital’ Great Wall of China so that our website can work as viewed outside of China. We will be using an alternative font library that reflects Google fonts and libraries, but first we will have to take some measures to identify users who are from China.

back to menu ↑

Identification of the user location

To begin with, we will have to find where our visitor is from and to do this we will use this WIPMania API which can retrieve a visitor’s geolocation including their country name:

$ .getJSON (‘http://api.wipmania.com/jsonp?callback=?’, function (data) {swal (‘You’re from’, data.address.country);});

We use jQuery $ .getJSON to call the API. We then pass data.address.country which should tell us where the visitor is coming from. Here’s a demo.

back to menu ↑

Alternative web font source

Now that we can find out our visitor location, we are going to replace Google Fonts with Useso Libraries, a CDN service that mirrors fonts and libraries from Google API, to serve visitors from China.

At this stage we still have our font styles referring to Google API:

We will replace the href within the link element with a JavaScript function.

function replaceGoogleCDN () {$ (‘link’). each (function () {var $ intial = $ (this) .attr (‘href’), $ replace = $ intial.replace (‘// fonts.googleapis.com /’, ‘//fonts.useso.com/ ‘); $ (this) .attr (‘ href ‘, $ replace);});}

This function replaces any link to point to //fonts.useso.com/ instead of the Google API address //fonts.googleapis.com/.

The feature will only work if the visitor is from CN, China’s international country code.

$ .getJSON (‘http://api.wipmania.com/jsonp?callback=?’, function (data) {if (data.address.country_code == ‘CN’) {replaceGoogleCDN ();}});

We are all ready. Visitors from China will now be offered fonts via //fonts.useso.com/ which is not blocked by the Chinese government.

back to menu ↑

Fix ‘Google Fonts Not Working in China’ Issue: benefits

  • The Fix ‘Google Fonts Not Working in China’ Issue tutorial is free .
  • This guide already helps so many users follow up with interest in a timely manner.
  • The price of the Fix ‘Google Fonts Not Working in China’ Issue guide is free.

back to menu ↑

Faq

Tutorial summary of Fix ‘Google Fonts Not Working in China’ Issue

In this guide, we told you about the Fix ‘Google Fonts Not Working in China’ Issue; please read all steps so that you understand Fix ‘Google Fonts Not Working in China’ Issue in case if you need any assistance from us, then contact us.

How this tutorial helping you?

So in this guide, we discuss the Fix ‘Google Fonts Not Working in China’ Issue, which undoubtedly helps you.

What is actual time in which this method complete?

The time to complete the Fix ‘Google Fonts Not Working in China’ Issue tutorial is 10+ minutes.

What are the supported Device?

PC Laptop or Desktop


back to menu ↑

Final note

I hope you like the guide Fix ‘Google Fonts Not Working in China’ Issue. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.

For our visitors: If you have any queries regards the Fix ‘Google Fonts Not Working in China’ Issue, then please ask us through the comment section below or directly contact us.
Education: This guide or tutorial is just for educational purposes.
Misinformation: If you want to correct any misinformation about the guide “Fix ‘Google Fonts Not Working in China’ Issue”, then kindly contact us.
Want to add an alternate method: If anyone wants to add more methods to the guide Fix ‘Google Fonts Not Working in China’ Issue, then kindly contact us.
Our Contact: Kindly use our contact page regards any help. You may also use our social and accounts by following us on Whatsapp, Facebook, and Twitter for your questions. We always love to help you. We answer your questions within 24-48 hours (Weekend off).
Channel: If you want the latest software updates and discussion about any software in your pocket, then here is our Telegram channel.

Compsmag
Logo