Skip to content

Instantly share code, notes, and snippets.

@Asikur22
Created February 29, 2024 01:29
Show Gist options
  • Save Asikur22/c23fe08c979553aa0c0980115a545a04 to your computer and use it in GitHub Desktop.
Save Asikur22/c23fe08c979553aa0c0980115a545a04 to your computer and use it in GitHub Desktop.
Preconnect Custom CDN
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