I want to host Google fonts locally to hopefully shave some page loading time off.
I hope to use google-webfonts-helper to do this.
I would need to ensure our theme, Divi, does not load the original Google fonts.
Currently, our site has the following in the head.
<link data-asynced='1' as='style' onload='this.rel="stylesheet"' rel='preload' id='divi-fonts-css' href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800&subset=latin,latin-ext' type='text/css' media='all' />
In /Divi/core/functions.php
, there is:
if ( ! function_exists( 'et_core_get_main_fonts' ) ) :
function et_core_get_main_fonts() {
global $wp_version;
if ( version_compare( $wp_version, '4.6', '<' ) ) {
return '';
}
$fonts_url = '';
/* Translators: If there are characters in your language that are not
* supported by Open Sans, translate this to 'off'. Do not translate
* into your own language.
*/
$open_sans = _x( 'on', 'Open Sans font: on or off', 'Divi' );
if ( 'off' !== $open_sans ) {
$font_families = array();
if ( 'off' !== $open_sans )
$font_families[] = 'Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800';
$protocol = is_ssl() ? 'https' : 'http';
$query_args = array(
'family' => implode( '%7C', $font_families ),
'subset' => 'latin,latin-ext',
);
$fonts_url = add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" );
}
return $fonts_url;
}
endif;
if ( ! function_exists( 'et_core_load_main_fonts' ) ) :
function et_core_load_main_fonts() {
$fonts_url = et_core_get_main_fonts();
if ( empty( $fonts_url ) ) {
return;
}
wp_enqueue_style( 'et-core-main-fonts', esc_url_raw( $fonts_url ), array(), null );
}
endif;
How would I stop the Divi theme from loading the Google font?
Do I need to disable the function et_core_load_main_fonts
?
Help appreciated.