Viewing 30 posts - 1 through 30 (of 38 total)
  • Author
  • #926056

    this thread and the code of Josue is a bit older –
    How do i prevent loading of google fonts via google page.
    I want to host them by myself – and only want to use what is needed.

    you can see here the google webfont helper – so you can choose the fonts wanted and download them – and load them localy.
    this is nice to have and not only because of “add expires header” … on gtmetrix and consorten


    edit : i tested it on a playground of mine. (

    The code of Josue still seams to work :

    add_action( 'init', 'enfold_customization_switch_fonts' );
    function enfold_customization_switch_fonts() {
        global $avia;
        $avia->style->print_extra_output = false;

    i wrote a little plugin to include and load my needed google fonts localy. (see how to here)
    via the google fonts helper

    so for me this is for an existing webpage better – for developing the page and customer response i like to change webfonts quick via enfold embedding – after the page is online – i will go this way then

    • This reply was modified 5 years, 11 months ago by Guenni007.

    Hi Guenni007,

    Thanks for sharing! Would you consider adding to as well? :)



    that little plugin is easy to make but – to download the files and to put in the css is the work that had to be done manually.

    that is the folder structure:

    this is the php of that plugin:

    Plugin Name: Local Google Web Fonts
    Description: Code to host Google Fonts locally
    Version: 1.0
    /* Start Adding Functions Below this Line */
    function local_google_fonts() {
    wp_enqueue_style( 'LocaleGoogleWebfonts', plugin_dir_url( __FILE__ ) .'assets/css/fonts.css' );
    add_action( 'wp_enqueue_scripts', 'local_google_fonts' );

    css is what you get on
    the fonts downloaded there comes into the fonts folder (on that case it is only comfortaa in it) of that plugin (see structure above)



    Thanks for that Günter! I will add it to GitHub library as courtesy of yours :)

    Best regards,


    Hello, everybody,

    unfortunately I cannot update to Enfold 4.3 or higher for a customer, because the hoster only provides php 5.3. Therefore I have to try to host the Google fonts locally. But: unfortunately it doesn’t work.

    Neither with the plugin of @Guenni007, nor after the steps of the instructions on these pages
    I always get a connection to Google.

    What can I do?
    Thanks and Best regards,


    I just fiddled to get rid of google fonts. Wondered why the fonts path used in my child theme’s style.css wouldn’t be recognized. I had to disable “CSS file merging and compression” setting in the Enfold performance options. Only then it worked and my local fonts are used.

    I also use

    add_action( 'init', 'enfold_customization_switch_fonts' );
    function enfold_customization_switch_fonts() {
        global $avia;
        $avia->style->print_extra_output = false;

    in my child theme’s function.php. But still there is a Roboto font loaded from (,400,500,700). I cannot find the source of this request. Website in question is

    Any help?



    I just filtered css files in the network and found this:
    Roboto loaded by common.js

    So it’s common.js that loads Roboto from

    And where is common.js located? Here:

    So the Google maps load Google fonts. Plausible.

    But how can I prevent that and force common.js to use the local font? Possible?

    • This reply was modified 5 years, 9 months ago by Stephan_H. Reason: Removed obsolete information

    OK, here’s the solution. Thanks to

    1. Create a /js/norobotofontbymaps.js in your child theme folder.
    2. Put this code into norobotofontbymaps.js:
      var head = document.getElementsByTagName('head')[0];
      // Save the original method
      var insertBefore = head.insertBefore;
      // Replace it!
      head.insertBefore = function (newElement, referenceElement) {
          if (newElement.href && newElement.href.indexOf('//') > -1) {
    'Prevented Roboto from loading!');
, newElement, referenceElement);
    3. Add this code to your functions.php:
      /*prevent roboto fonts loaded by google maps api*/
      $child_theme_url = get_stylesheet_directory_uri();
      wp_register_script( 'norobotofontbymaps', $child_theme_url.'/js/norobotofontbymaps.js', 'jquery', "1", true);
      wp_enqueue_script( 'norobotofontbymaps' );

    That’s it. No connections to anymore. :)

    • This reply was modified 5 years, 9 months ago by Stephan_H. Reason: corrected a typo


    Great, glad you found a solution and thanks a lot for sharing. Much appreciated :-)

    Best regards,


    Has Basilis not announced a theme updated concerning this and other GDPR features for ENFOLD until May 25 in another thread?


    Hi Gitte,

    We are planning to release the new version of the theme on the 22nd of this month.

    Best regards,


    Hi @Stephan_H,

    thank you so much for the solution!!!
    That’s exactly what I was looking for :))

    Best regards,


    I followed the instructions here for the plugin and it worked so far really good. But there are two problems now:

    • The size of the font is not correct anymore for the header, it seems that the size setting is not used anymore
    • The header of a is not centered anymore

    Is this happening to other also?

    Best Regards,

    • This reply was modified 5 years, 9 months ago by Shashahan.

    @Shashahan: I would determine the css class of the affected elements and overwrite size and position in the style.css of your child theme (or in the Enfold Quick CSS settings).



    Thanks for helping out @stephan_H, did you try that out @shashahan?

    Best regards,


    thank you @stephan_h for your answer but i am no good with css at all. I don’t even know where to begin :/
    I decided to use the route with @font-face entries in custom.css and the function below as i am not planning to change the fonts often .

    It seems that a lot of the general styling is ignored when i use the function `add_action( ‘init’, ‘enfold_customization_switch_fonts’ );
    function enfold_customization_switch_fonts() {
    global $avia;
    $avia->style->print_extra_output = false;

    Before the change it looked like that:
    Home: Home before the change to local fonts
    Post: Post before the change to local fonts

    After the change:
    Home: Home after the change to local fonts
    Post: Post after the change to local fonts

    Is it planned to have an option to load fonts from local storage without disabling the design (font size and position) of the theme to be compliant with the GDPR (DSGVO)?

    Best Regards,


    Hi Shashahan,

    The option of uploading fonts to your server is available now in Enfold 4.4.

    Please update.

    Best regards,


    Hallo Zusammen,

    Vielen Dank für Eure wirklich tolle „DSGVO“ Arbeit nach dem Update und die Möglichkeit „Google Fonts“ nun auch Local zu speichern

    Ich habe „Open Sans“ als .zip Datei runtergeladen und eingebunden.

    Und im Editor „Open Sans“ die Locale Version ausgewählt.

    Meine Frage, ist damit „Google Fonts“ getrennt von der Webseite, oder muss noch etwas im Quellcode verändert werden, damit an „Google“ nicht mehr die IPs übertragen werden?

    Herzliche Grüße




    Wenn kein google font ausgewählt wurde, dann wird auch kein google font js vom theme mitgeladen.

    Um ganz sicher zu sein, dass vom Theme aus auch nichts geladen wird, gibt es ein filter (enfold\framework\php\class-style-generator.php function link_google_font() Zeile 482):

    if( true != apply_filters( 'avf_output_google_webfonts_script', true ) )
        return '';



    @Günter: Wo muss ich denn den Filter “avf_output_google_webfonts_script” setzen und wie?


    Hallo Günter,

    die Zeile 482 habe ich gefunden:

    if( true != apply_filters( 'avf_output_google_webfonts_script', true ) )
        return '';

    Ich bin kein Programmierer! Muss daran etwas geändert werden?

    Herzliche Grüße




    Wenn Du in functions.php des Child Themes (oder des Hauptthemes, wenn Du kein Child Theme verwendest) am Ende das folgende einfügst (z.B. über Dashboard -> Appearance > Editor):

    add_filter( 'avf_output_google_webfonts_script', 'my_output_google_webfonts_script', 10, 1 );
    function my_output_google_webfonts_script( $activate )
    	return false;

    dann ist sichergestellt, dass der Google js nie geladen wird, auch falls Du versehentlich einen Google Font auswählen solltest.

    Best regards,


    @ Günter, Herzlichen Dank


    Is this solution part of the next update of enfold?
    Thank you for your solution.


    Hi royaltask,

    NO, this is just a piece of code to be used if need to completely disable loading Google fonts by Enfold.

    If you need further assistance please let us know.
    Best regards,


    This script is not working here,
    I added it to functions (child) at the very bottom … Roboto 100, 400, 700 is still loading from googleapi. I do not even use this Font on my site or Plugins. Where does it come from?

    add_filter( 'avf_output_google_webfonts_script', 'my_output_google_webfonts_script', 10, 1 );
    function my_output_google_webfonts_script( $activate )
    	return false;

    Note: I deleted cache and tested on different computers. Still Googlefontsloading, …

    • This reply was modified 5 years, 8 months ago by royaltask.

    @royaltask: Do you use Google Maps? Maps load Roboto fonts on their own. Solution see post #958964 above.


    I have google Maps disabled (JS Consent) and deleted the cache, still loading Google Fonts. Code was added as listed above.

    • This reply was modified 5 years, 8 months ago by royaltask.

    I found this in my header souce code on all pages:
    Where does it come from?

    <!-- google webfont font replacement -->
    			<script type='text/javascript'>
    				(function() {
    					var f = document.createElement('link');
    					f.type 	= 'text/css';
    					f.rel 	= 'stylesheet';
    					f.href 	= '//,400,700'; 	= 'avia-google-webfont';

    Oh no!!! I found this, is the next Update of Enfold with this patch!?

    • This reply was modified 5 years, 8 months ago by royaltask.
Viewing 30 posts - 1 through 30 (of 38 total)
  • The topic ‘Disable google font loading via google’ is closed to new replies.