technically AO removes CSS that is loaded from fonts.googleapis.com
, if fonts are loaded locally, they’re not caught and hence not removed.
If you can provide me with a link to your site where I can see the local Google fonts being loaded, I _might_ be able to come up with a workaround (a code snippet).
Thanks for the offer. Was just curious if you could change something in the plugin itself to account for the new WordPress change. It is not a major speed issue so I will hold off (might get a new theme with different fonts in the near future anyway).
I’ll test one of these days with one of the twenty-xyz themes and see what can be done.
Can you test for WordPress Twenty Fourteen? It is loading at least 5-6 fonts and slowing down my site load by a full second.
Quick test sees wp-content/themes/twentyfourteen/fonts/font-lato.css
being loaded which loads locally hosted fonts, so not really Google Fonts.
But if you do want to remove those you could use a snippet like this (untested) one;
add_filter(
'autoptimize_filter_css_removables',
function ( $in ) {
return $in . ', wp-content/themes/twentyfourteen/fonts/font-lato.css';
}
);
hope this helps,
frank
I messages you on Twitter. Did not want to post my domain and GTMetrix waterfall link here.
Well, you waterfall chart does not contain fonts loaded from the Google domain, the fonts are loaded from your own domain, so technically those are not Google Fonts any more 🙂
If you don’t want the lato fonts to load, you can try try the code snippet I posted above?
Thanks! Which file should the snippet be added into? This problem only started after the WordPress “dolphy” update this year FYI.
The easiest & safest solution is using the code snippets plugin 🙂
The last thing I like to do is add more plugins if possible 🙁 Even the best reviewed ones cause issues down the road and add extra code, show up in error logs etc. Even 8 years after I removed several well known ones (such as Wordfence), their names show in Google Search Console “Pages” section error breakouts.
well, you can always add the code to your theme’s functions.php, but do take into account (and that’s why I advice against it) that that file gets overwritten with every theme update 🙂
Makes sense, thanks again!