Deactivate link to fonts.googleapis.com

I tried to use fonts without a Google-Server Connection. For this I put the following code to the additional css (Customizer): /* exo-2-regular - latin */

    @font-face {
      font-family: 'Exo 2';
      font-style: normal;
      font-weight: 400;
      src: url('../fonts/exo-2-v4-latin-regular.eot'); /* IE9 Compat Modes */
      src: local('Exo 2'), local('Exo2-Regular'),
           url('../fonts/exo-2-v4-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
           url('../fonts/exo-2-v4-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
           url('../fonts/exo-2-v4-latin-regular.woff') format('woff'), /* Modern Browsers */
           url('../fonts/exo-2-v4-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
           url('../fonts/exo-2-v4-latin-regular.svg#Exo2') format('svg'); /* Legacy iOS */
    }

It works fine but the following code is still in the code.

<link rel='dns-prefetch' href='//fonts.googleapis.com' />

Sure I can remove it but only until the next update.
I installed the Remove Google Fonts References Addon but nothing happens.
How can I manage it? I have the same problems with Moesia Theme.
Thanks for helping

Hello there,

You can remove it safely with this function:

    function sydney_child_remove_googlefont() {

       wp_dequeue_style( 'sydney-fonts' );

    }
    add_action( 'wp_enqueue_scripts', 'sydney_child_remove_googlefont', 999 ); 

Add it to your child theme’s functions.php file. Or you can use Code Snippets plugin without running a child theme.

Regards,
Kharis

Thank you! And what about Moesia?
I would like to remove the google font extension plugin
Regards,
Regina

Hello there,

For Moesia, which has different handler names, you can use this code:

    function moesia_child_remove_googlefont() {

       wp_dequeue_style( 'moesia-headings-fonts' );
       wp_dequeue_style( 'moesia-roboto-condensed' );
       wp_dequeue_style( 'moesia-body-fonts' );
       wp_dequeue_style( 'moesia-roboto' );

    }
    add_action( 'wp_enqueue_scripts', 'moesia_child_remove_googlefont', 999 ); 

Regards,
Kharis

Sorry but it’s still there. If you can see on https://krankengymnastik-smit.de or https://osteopathie-smit.de
The system is loading Roboto from Google …I don’t know why

Hello there,

Viewing the source code of your sites and I didn’t find ny Roboto font hosted from Google in there. Try clearing web browser’s cache/history. https://codex.wordpress.org/I_Make_Changes_and_Nothing_Happens

Regards,
Kharis

I cleared the cache but if you look to the firefox inspector you’ll find this:
https://fonts.googleapis.com/css?family=Roboto:300,400,500,700
So there’s still a connection to Google-Server

Hi again,
still the same problem. This is what I did:
Following code in the functions.php of Moesia Child-Theme:

function moesia_child_remove_googlefont() {

   wp_dequeue_style( 'moesia-headings-fonts' );
   wp_dequeue_style( 'moesia-roboto-condensed' );
   wp_dequeue_style( 'moesia-body-fonts' );
   wp_dequeue_style( 'moesia-roboto' );

}
add_action( 'wp_enqueue_scripts', 'moesia_child_remove_googlefont', 999 ); 

In customizer/css:
/* Body font */
body, h1, h2, h3, h4, h5, h6, .main-navigation li, .fact, .all-news, .welcome-button, .call-to-action .employee-position, .post-navigation .nav-previous, .post-navigation .nav-next, .paging-navigation .nav-previous, .paging-navigation .nav-next {
font-family: ‘Exo’, sans-serif !important;
}

and the styles from the google webfonts helper for Exo and Roboto.
The fonts are in the right folder on the server.
But if you have a look to the network soruces in firefox there’s still a connection with the Google Font Server. Could you please help?

Hello there,

From your site dashboard, visit Appearance > Customize > Fonts. Then select any font for "
Select your desired font for the headings.", except Roboto.

Regards,
Kharis

smit und partner, designer | design und usability

smit und partner, designer | design und usability