0

I’m using the Escutcheon theme, version 1.0.8. After searching through all of my theme's files, the only place that I see Google Fonts referenced is in functions.php.

Is dequeueing Google Fonts in my child functions.php file sufficient to prevent Google Fonts from loading on my site, or will

$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );

in my parent functions.php file still trigger the call to the Google Font servers even if the child functions.php file dequeues it?

Here is the child functions.php code that I am hoping will block the connection to Google Fonts entirely:

add_action( 'wp_print_styles', 'tn_dequeue_escutcheon_fonts_url()' ); function tn_dequeue_escutcheon_fonts_url() { wp_dequeue_url( 'https://fonts.googleapis.com/css' ); }

Any feedback would be greatly appreciated!

0

Dequeueing the enqueued style will be sufficient. But you need to be careful to dequeue it after it is enqueued. It is enqueued at the default priority of 10, so make sure that when you hook into wp_enqueue_scripts you do so at a higher/later priority.

add_action( 'wp_enqueue_scripts', 'wpse_escutcheon_scripts', 11 );
function wpse_escutcheon_scripts() {
  wp_dequeue_style( 'escutcheon-fonts' );
}
  • Thank you very much Nathan, both for your explanation and for your code! Your addition to my child functions.php file works visually exactly as I wanted. Is there a way that I can test whether or not Google Fonts - or any other unwanted CDN - is still being called and connecting to my website? (My preferred browser is Firefox, if it's relevant.) My goal is the leanest, fastest, and most user privacy respecting blog I can put together. – Nocturnum Nov 19 '17 at 4:07
  • View the source code in your browser. Search for 'escutcheon-fonts-css'. There should be no matches. – Nathan Johnson Nov 19 '17 at 4:22
  • Confirmed. In Firefox 57 the source code of any given webpage can be accessed via "Tools" > "Web Developer" > "Page Source", or simply [Command]+[U]. In addition to your recommended search I also did a search for 'google', and found no link to fonts.googleapis.com. Thanks again Nathan! – Nocturnum Nov 19 '17 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.