Reply To: Change dns-prefetch to preconnect

Home Forums Support Change dns-prefetch to preconnect Reply To: Change dns-prefetch to preconnect

Home Forums Support Change dns-prefetch to preconnect Reply To: Change dns-prefetch to preconnect

#227032
Tom
Lead Developer
Lead Developer

You had me at “speed” ๐Ÿ™‚

Been looking at this while trying to do it with core WP functions.

Looks like they added a function in WP 4.6 to help with this.

However, I’m not seeing massive speed improvements.

Can you try testing with this function?:

if ( ! function_exists( 'generate_typography_resource_hints' ) ) :
add_filter( 'wp_resource_hints', 'generate_typography_resource_hints', 10, 2 );
function generate_typography_resource_hints( $hints, $relation_type ) {	
	if ( 'preconnect' === $relation_type ) {
        $hints[] = '//fonts.gstatic.com';
    }
 
    return $hints;
}
endif;