Created
February 29, 2024 01:29
-
-
Save Asikur22/c23fe08c979553aa0c0980115a545a04 to your computer and use it in GitHub Desktop.
Preconnect Custom CDN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'wp_resource_hints', 'preconnect_custom_cdn', 99, 2 ); | |
function preconnect_custom_cdn( $urls, $relation_type ) { | |
if ( $relation_type == 'preconnect' ) { | |
$urls[] = [ | |
'href' => 'https://fonts.googleapis.com', | |
]; | |
$urls[] = [ | |
'href' => 'https://fonts.gstatic.com', | |
'crossorigin' => true | |
]; | |
} | |
return $urls; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment