Created
September 4, 2014 03:27
-
-
Save bhubbard/34fa8d2222eb2d1bc6d6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
// Prefetch For Speed Up | |
function dns_prefetch() { | |
$prefetch = 'on'; | |
echo "\n <!-- DNS Prefetching Start --> \n"; | |
echo '<meta http-equiv="x-dns-prefetch-control" content="'.$prefetch.'">'."\n"; | |
if ($prefetch != 'on') { | |
$dns_domains = array( | |
"//use.typekit.net", | |
"//netdna.bootstrapcdn.com", | |
"//cdnjs.cloudflare.com", | |
"//ajax.googleapis.com", | |
"//s0.wp.com", | |
"//s.gravatar.com", | |
"//stats.wordpress.com", | |
"//www.google-analytics.com" | |
); | |
foreach ($dns_domains as $domain) { | |
if (!empty($domain)) echo '<link rel="dns-prefetch" href="'.$domain.'" />'."\n"; | |
} | |
unset($domain); | |
} | |
echo "<!-- DNS Prefetching end --> \n"; | |
} | |
add_action( 'wp_head', 'dns_prefetch', 0 ); | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment