Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of prohibiting WordPress header from loading s.w.org

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report