The method of prohibiting WordPress header from loading s.w.org
This article mainly introduces the method of prohibiting WordPress head loading s.w. org. The introduction in the article is very detailed and has certain reference value. Interested friends must read it!
abstract
WordPress in the head to add dns-prefetch, should be in order to pre-obtain expressions and avatars from s.w.org, the purpose is to improve the page loading speed, but s.w.org can not be accessed at all, what pre-acquisition, what to improve the speed, are bubbles, not only useless, but may affect the speed, then prohibit it.
Prohibiting WordPress Head Loading s.w.org
After upgrading to WordPress 4.6, some children found that the header loaded a:
WordPress in the head to add dns-prefetch, should be in order to pre-obtain expressions and avatars from s.w.org, the purpose is to improve the page loading speed, but s.w.org can not be accessed at all, what pre-acquisition, what to improve the speed, are bubbles, not only useless, but may affect the speed, then prohibit it.
Add the following code to the theme functions.php template:
method one
remove_action( 'wp_head', 'wp_resource_hints', 2 );
methodology II
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 2 seems to be more compatible.
Comes with a ban on loading emoji code
// Remove emoji scriptremove_action ('wp_head','print_emoji_detection_script', 7 );remove_action ('wp_print_styles','print_emoji_styles');add_filter ('emoji_svg_url','__return_false'); All of the above are ways to disable WordPress headers from loading s.w.org, thanks for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!