• Resolved kallym

    (@kallym)


    The Photo Gallery plugin seems to be loading (lots of) Google Fonts on the front end and GTMEtrix is giving us Minimize Request Size warnings that say: The requests for the following URLs don’t fit in a single packet. Reducing the size of these requests could reduce latency.

    The function is in photo-gallery.php and is called function bwg_styles() and is creating 5 stylesheets to load Google fonts.

    I tried this in my child theme function.php file but it didn’t work:

    function unload_fonts() {
              wp_dequeue_style( 'bwg_googlefonts_0-css');
    		  wp_dequeue_style( 'bwg_googlefonts_150-css');
    		  wp_dequeue_style( 'bwg_googlefonts_300-css');
    		  wp_dequeue_style( 'bwg_googlefonts_450-css');
    		  wp_dequeue_style( 'bwg_googlefonts_600-css');
           }
    
    add_action('wp_enqueue_scripts', 'unload_fonts', 100);

    Can you please let me know how to disable this or block this from happening?

    Thank you!

Viewing 7 replies - 1 through 7 (of 7 total)
  • As I was looking through the code of the latest version of Photo Gallery, I found this part in the plugins/photo-gallery/photo-gallery.php file:

    // Google fonts.
    require_once(WD_BWG_DIR . ‘/framework/WDWLibrary.php’);
    for ($i = 0; $i < count($google_fonts); $i = $i + 120) {
    $fonts = array_slice($google_fonts, $i, 120);
    $query = implode(“|”, str_replace(‘ ‘, ‘+’, $fonts));
    $url = ‘https://fonts.googleapis.com/css?family=&#8217; . $query . ‘&subset=greek,latin,greek- ext,vietnamese,cyrillic-ext,latin-ext,cyrillic’;
    wp_enqueue_style(‘bwg_googlefonts_’ . $i, $url, null, null);
    }
    }
    add_action(‘wp_enqueue_scripts’, ‘bwg_front_end_scripts’);

    So the actual handles are as follow ‘bwg_googlefonts_0’, ‘bwg_googlefonts_120’, ‘bwg_googlefonts_240’, ‘bwg_googlefonts_360’, ‘bwg_googlefonts_480’, ‘bwg_googlefonts_600’.

    Would also like this code removed. No reason to load EVERY Google font in the world. Let me know if you figure out a way to fix this.

    Thread Starter kallym

    (@kallym)

    Thanks Spinaker, but the plugin was just updated in the last 24 hours. The version I downloaded a few days ago had 150 instead of 120. ie. $i = $i + 150. So my code shows 150. It doesn’t matter, I just changed the function to 0, 120, 240, 360, 480 and 600 and it still doesn’t work.

    RockyReasoner, yes, it looks like the plugin is loading 6 different stylesheets for 150 Google Fonts, and those stylesheets are loading the fonts.

    The number of fonts involved is causing GTMetrix to report that I should minimize request size and says: The requests for the following URLs don’t fit in a single packet. Reducing the size of these requests could reduce latency.

    You can see from the following example that this is ridiculous and this is just for 120 – there are 6 in all. We are forced to load Google Fonts we don’t need. I checked the updated options and there is no where to disable this and the standard methods for creating child theme functions to over ride these are not working for me. I ended up commenting out code in the plugin itself, but this will be overwritten the next time there is an update, so not an acceptable solution!

    Can the Photo Gallery moderator please comment on this?

    example for 120:

    <link
    rel='stylesheet' id='bwg_googlefonts_120-css'  href='https://fonts.googleapis.com/css?family=Carrois+Gothic+SC|Carter+One|Caudex|Caveat+Brush|Cedarville+Cursive|Ceviche+One|Changa+One|Chango|Chau+Philomene+One|Chela+One|Chelsea+Market|Chenla|Cherry+Cream+Soda|Chewy|Chicle|Chivo|Chonburi|Cinzel|Cinzel+Decorative|Clicker+Script|Coda|Coda+Caption|Codystar|Combo|Comfortaa|Coming+Soon|Concert+One|Condiment|Content|Contrail+One|Convergence|Cookie|Copse|Corben|Courgette|Cousine|Coustard|Covered+By+Your+Grace|Crafty+Girls|Creepster|Crete+Round|Crimson+Text|Croissant+One|Crushed|Cuprum|Cutive|Cutive+Mono|Damion|Dancing+Script|Dangrek|Dawning+of+a+New+Day|Days+One|Dekko|Delius|Delius+Swash+Caps|Delius+Unicase|Della+Respira|Denk+One|Devonshire|Dhurjati|Didact+Gothic|Diplomata|Diplomata+SC|Domine|Donegal+One|Doppio+One|Dorsa|Dosis|Dr+Sugiyama|Droid+Sans|Droid+Sans+Mono|Droid+Serif|Duru+Sans|Dynalight|EB+Garamond|Eagle+Lake|Eater|Economica|Eczar|Ek+Mukta|Electrolize|Elsie|Elsie+Swash+Caps|Emblema+One|Emilys+Candy|Engagement|Englebert|Enriqueta|Erica+One|Esteban|Euphoria+Script|Ewert|Exo|Exo+2|Expletus+Sans|Fanwood+Text|Fascinate|Fascinate+Inline|Faster+One|Fasthand|Fauna+One|Federant|Federo|Felipa|Fenix|Finger+Paint|Fira+Mono|Fjalla+One|Fjord+One|Flamenco|Flavors|Fondamento|Fontdiner+Swanky|Forum|Francois+One|Freckle+Face|Fredericka+the+Great|Fredoka+One|Freehand|Fresca&subset=greek,latin,greek-ext,vietnamese,cyrillic-ext,latin-ext,cyrillic' type='text/css' media='all' />
    Sona

    (@support-web-dorado)

    Dear users,

    In January we will release an update which will fix the Google Font inclusion. Thanks.

    Thread Starter kallym

    (@kallym)

    Thank you!! ??

    I’m not sure if this has been updated or not, but my error is a little different.

    Its causing a 400 status error on the URL query because there is no font name being loaded.

    https://fonts.googleapis.com/css?family=&subset=greek,latin,greek-ext,vietnamese,cyrillic-ext,latin-ext,cyrillic

    This might have something to do with the new Google Fonts system or something not working with the from what I understand attempt to load all of the google fonts. You also don’t need every single subset. Just latin or the ability to enable/disable.

    Not to mention I can’t even find anywhere in the plugin’s settings where these Google Fonts can be set/customized/disabled/enabled/etc.

    I’m also getting an XMLHttpRequest warning that you may want to address. Not a bug or anything of course I’m sure you guys are aware of this outdated method.

    • This reply was modified 7 years, 10 months ago by leaninonlife.

    BTW Technically the style that gets enqueued by the plugin is ‘bwg_googlefonts’ on line 2253 in photo-gallery.php during the global inline style script, so adding wp_dequeue_style(‘bwg_googlefonts’); instead would be the quickest easiest route to removing the google fonts from loading on all of your pages.

    function unload_fonts() {
    		  wp_dequeue_style( 'bwg_googlefonts');
           }
    
    add_action('wp_enqueue_scripts', 'unload_fonts', 100);

    And if you want to get rid of the rest of the plugin’s bloat I recommend de-queuing the scripts and styles that in my case are not needed either…

    function unload_dwgbloat() {
    		  wp_dequeue_style( 'bwg_googlefonts');
    		  wp_dequeue_style( 'bwg_mCustomScrollbar');
    		  wp_dequeue_style( 'bwg_sumoselect');
    		  wp_dequeue_script( 'bwg_sumoselect');
    		  wp_dequeue_script( 'bwg_mCustomScrollbar');		 
           }
    
    add_action('wp_enqueue_scripts', 'unload_dwgbloat', 100);

    This worked for me…

    • This reply was modified 7 years, 10 months ago by leaninonlife.
    • This reply was modified 7 years, 10 months ago by leaninonlife.
    • This reply was modified 7 years, 10 months ago by leaninonlife.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Remove Google Fonts’ is closed to new replies.