The following column WordPresstutorial will introduce to you how to disable the WordPress header from loading s.w.org. I hope it will be helpful to friends in need!
Abstract
WordPress adds dns-prefetch in the header, which should be to pre-fetch emoticons and avatars from s.w.org. The purpose It is to improve the loading speed of web pages, but s.w.org is not accessible at all in China. Any pre-fetching or speed improvement are all in vain. Not only is it useless, but it may affect the speed, so ban it.
Prohibit WordPress header from loading s.w.org
After upgrading to WordPress 4.6, some children found that the header was loaded:
<link rel='dns-prefetch' href='//s.w.org'>
WordPress in the header The purpose of adding dns-prefetch is to pre-fetch emoticons and avatars from s.w.org. The purpose is to improve the loading speed of web pages. However, s.w.org is simply inaccessible in China. Any pre-fetching or speed-improving methods are in vain. Not only are they useless, but they are actually It might affect the speed, so disable it.
Add the following code to the theme functions.php template:
Method one
remove_action( 'wp_head', 'wp_resource_hints', 2 );
Method two
function remove_dns_prefetch( $hints, $relation_type ) { if ( 'dns-prefetch' === $relation_type ) { return array_diff( wp_dependencies_unique_hosts(), $hints ); } return $hints; } add_filter( 'wp_resource_hints', 'remove_dns_prefetch', 10, 2 );
Method two seems to have better compatibility .
Comes with an emoticon code that prohibits loading
// Remove emoji script remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); add_filter( 'emoji_svg_url', '__return_false' );
Recommended tutorial column: "WordPress imitation site"
The above is the detailed content of How to disable WordPress headers from loading s.w.org. For more information, please follow other related articles on the PHP Chinese website!