Forbid WordPress header from loading s.w.org

WordPress sixty 14.1K Reading mode
abstract WordPress should add dns prefetch to its header in order to pre acquire emoticons and avatars from s.w.org, in order to improve the speed of page loading, but s.w.org is not accessible in China at all, so what is pre acquired and what is faster

 

 Forbid WordPress header from loading s.w.org

After upgrading to WordPress 4.6, a child shoe found that a:

<link rel='dns-prefetch' href='//s.w.org'>

WordPress should add dns prefetch to the header in order to s.w.org Pre acquire emoticons and avatars to improve the speed of web page loading, but s. W.org is not accessible in China, Any pre acquisition or speed increase is a bubble. It is not only useless, but may affect the speed. It is prohibited.

Add the following code to the theme functions.php template:

Method 1

  1. remove_action( 'wp_head', 'wp_resource_hints', 2 );

Method 2

  1. function remove_dns_prefetch( $hints , $relation_type ) {
  2. if ( 'dns-prefetch' === $relation_type ) {
  3. return array_diff ( wp_dependencies_unique_hosts(), $hints );
  4. }
  5. return $hints ;
  6. }
  7. add_filter( 'wp_resource_hints', 'remove_dns_prefetch', 10, 2 );

Method 2 seems to be more compatible.

Attached is a forbidden emoticon code

  1. // Remove emoji script
  2. remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
  3. remove_action( 'wp_print_styles', 'print_emoji_styles' );
  4. add_filter( 'emoji_svg_url', '__return_false' );

reference resources: https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/

Most of the articles on this site are original and used for personal learning records, which may be helpful to you, for reference only!

 weinxin
My Wechat
Copyright Notice
Please indicate the source and link of the original article reprinted on this site. Thank you for your cooperation!
five hundred and ninety-eight million eight hundred and forty-five thousand and six
 
 Robin
five hundred and ninety-eight million eight hundred and forty-five thousand and six
Comments sixty    Visitors sixty
    •  Pioneer Blog
      Pioneer Blog two

      The blogger is good at writing! give the thumbs-up :wink:  :wink:  :wink:

      •  Ink, water bottle
        Ink, water bottle four

        Well done! Give me a compliment!

        •  I love sports bike network
          I love sports bike network seven

           :wink: Thanks for sharing with Brother Bird. This is exactly what I have been looking for and eager for recently, because my blog was upgraded to 4.6 a few days ago.

          •  Gold Searching Notes
            Gold Searching Notes six

            awesome! practical

            •  Luotian Online
              Luotian Online one

               :cool: pretty good

              •  wechat Business
                wechat Business four

                That's to forbid her

                •  Taobao internal coupon
                  Taobao internal coupon two

                  It has been disabled. Drag website speed

                  •  Yang Zeye's Blog
                    Yang Zeye's Blog two

                    At present, there is no upgrade, because 4.6 is in English but not in Chinese, so I will not upgrade for fear of making mistakes

                      •  I love sports bike network
                        I love sports bike network seven

                        @ Yang Zeye's Blog I upgraded to 4.6 a few days ago, and I also upgraded to 4.6.1 yesterday. I didn't find any problems. If you have always used the simplified Chinese version, the direct background update will still be in Chinese. If the simplified Chinese version is updated later, the background can also update the translation.

                      •  synyan
                        synyan six

                        Good! I've been trying to remove this thing for years..

                        •  Front end rookie
                          Front end rookie zero

                          Pay attention when passing :razz:

                          •  madikar
                            madikar zero

                            good بىلىۋېلىشقا تېگىشلىك مۇھىم تېمىلارنىڭ بىرى ئىكەن

                            •  Long Xiaotian
                              Long Xiaotian five

                              You are also mirrored~ http://zmingcx.com.dijicat.com/
                              See here: http://www.ilxtx.com/mirrored-website.html I hope the blogger can improve Method 3, which has no effect in Firefox~

                              •  Midnight dream
                                Midnight dream four

                                The top setting function of the theme article of ality is invalid. Please fix it

                                •  Drip record
                                  Drip record three

                                  Good way :wink:

                                  •  Taobao internal coupon
                                    Taobao internal coupon two

                                    I like the theme of the blogger very much. I'll make one one someday

                                    •  Search blogger
                                      Search blogger one

                                      The problem was discovered just after upgrading 4.6, but Baidu didn't get relevant information at that time. Unexpectedly, Brother Bird has found the answer here! :grin:

                                      •  Microblog
                                        Microblog three

                                        Well, I can't help it. Foreign domain names are blocked at home

                                        •  good thing
                                          good thing zero

                                          Code Xiaobai doesn't know

                                          •  Fragment Art and Culture Record
                                            Fragment Art and Culture Record three

                                            The code is used, but it seems that there is no change!

                                            •  I love sports bike network
                                              I love sports bike network seven

                                               :idea: Looking forward to brother bird updating blog, bringing new wonderful sharing!

                                              •  American drama lovers
                                                American drama lovers two

                                                Brother Bird updates quickly

                                                •  Phoenix Military Video
                                                  Phoenix Military Video one

                                                  The article is good, support it

                                                  •  wsaddd
                                                    wsaddd zero

                                                     :mrgreen:  :mrgreen:  :mrgreen:  :mrgreen:  :mrgreen:  :mrgreen: This is good

                                                    •  Lin Xi Online Earning Technology Sharing Blog
                                                      Lin Xi Online Earning Technology Sharing Blog zero

                                                      Uncle Bird's technology is very good. He likes one and has already implemented it

                                                      •  maqingxi
                                                        maqingxi five

                                                        It has already been used. I feel much faster psychologically, hehe.

                                                        •  Take off your glasses ten minutes a day
                                                          Take off your glasses ten minutes a day zero

                                                          Thanks for sharing

                                                          •  Bili Welfare
                                                            Bili Welfare two

                                                            After using this code, the dns prefetch of the original cdn disappears. Is there any solution

                                                            •  Yunnan Cross Bridge Rice Noodles
                                                              Yunnan Cross Bridge Rice Noodles one

                                                              Well done! Give me a compliment!

                                                              •  Yunnan Cross Bridge Rice Noodles
                                                                Yunnan Cross Bridge Rice Noodles one

                                                                awesome! practical

                                                                •  Chrysanthemum
                                                                  Chrysanthemum four

                                                                  Thanks for sharing and removing all things that are not suitable for domestic display

                                                                  •  Hu Huanxin's Blog
                                                                    Hu Huanxin's Blog one

                                                                    Why can't I visit the website if I add this code....

                                                                    •  Hu Huanxin's Blog
                                                                      Hu Huanxin's Blog one

                                                                      Once I add this code, the whole website cannot be accessed. Where should I put this code

                                                                      •  Win7en Paradise
                                                                        Win7en Paradise seven

                                                                        I don't think the impact is too great, so I won't take it out

                                                                        •  pretty good
                                                                          pretty good zero

                                                                          ha-ha

                                                                          •  isher
                                                                            isher one

                                                                            In addition, s.w.org is not accessible nationwide. After testing, some provinces cannot access it. At the same time, an IP address is provided. Please join the host 192.229.144.127 to access it. At the same time, this address is also responsible for the thumbnail of plug-ins and themes, which will be called by the background. - The story writer is passing by

                                                                            •  isher
                                                                              isher one

                                                                              By the way, your article page is really stuck and dull~

                                                                              •  Win7en Paradise
                                                                                Win7en Paradise seven

                                                                                This is very practical, thank you!

                                                                                •  Suvan
                                                                                  Suvan one

                                                                                  six thousand six hundred and sixty-six :mrgreen: Collection

                                                                                  •  Thousands
                                                                                    Thousands zero

                                                                                    Eh, that website will not be redirected to https://wordpress.org/ Here

                                                                                    •  Tomato and potato chips
                                                                                      Tomato and potato chips one

                                                                                      What's the disadvantage of choosing the first method to remove dns prefetch? Why the second compatibility is better

                                                                                      •  My blog
                                                                                        My blog one

                                                                                        Can we only remove s.w.org and allow other dns prefetch. After hosting js to Baidu, the website will add link rel='dns prefetch' href='//apps. bdimg. com'/in the header, and Baidu will be banned by both methods. Note: The server is abroad

                                                                                        •  Pangu Technology
                                                                                          Pangu Technology zero

                                                                                          Thank you

                                                                                          •  Tiandi Hui
                                                                                            Tiandi Hui one

                                                                                            It seems useless. The status returned by http is still in it.

                                                                                            •  Lao Zhao
                                                                                              Lao Zhao zero

                                                                                              Pay attention when passing

                                                                                             anonymous

                                                                                            Comment

                                                                                            Anonymous netizens
                                                                                             :?:  :razz:  :sad:  :evil:  :!:  :smile:  :oops:  :grin:  :eek:  :shock:  :???:  :cool:  :lol:  :mad:  :twisted:  :roll:  :wink:  :idea:  :arrow:  :neutral:  :cry:  :mrgreen:

                                                                                            Drag the slider to complete validation