Clean up and Optimize WordPress Header Code

Notice a lot of extra code that appears unnecessary or “junk” in your website’s page source? As an advocate of clean and minimal page code ( pro-SEO, to some extent ) I like to optimize every single piece of code and keep things as clean and efficient as possible.

Let’s look at some of that seemingly unwanted stuff and an easy way to get rid of them.

Unnecessary junk in WordPress site’s header

Here’s an example of a WordPress website’s header with those extra rel, or meta lines of code. Each of these lines has a purpose. I, however, do not find value in the rel tags and their purpose and clean them up first thing post a fresh install. While that may be the case with you; take some time to understand what each line does and feel free to follow the steps to clean them all (or some).

unnecessary code in wordpress header

Let me explain a few of them:

Really Simple Discovery (RSD)


I’m talking about the code that generates this line in your WordPress blog:

<link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://www.bloghow.com/xmlrpc.php?rsd" />

This is an XML format and a publishing convention for making services exposed by your blog discoverable by client software. If you’ve no idea what this is, probably you’re not going to use it for connecting client software to your blog.

WP Generator

This displays the version of WordPress you’re using.

<meta name="generator" content="WordPress 5.4.1" />
Post Relational Links

Post relational links are, as the name suggests, the information about the relationship with some other pages. I didn’t really see a huge benefit from them.

Similarly, there are tags related to Feed Links and other stuff that aren’t really something useful to the vast majority of websites. However, there are some tags you shouldn’t remove, such as:

Canonical Tag

I would recommend you retain the canonical tag that outputs something like this:

<link rel="canonical" href="https://www.bloghow.com/how-to-start-a-blog.html" />

Canonical tags help avoid duplicate content issues with SEO. It helps search engines understand identical content under different URLs and helps them better index one version of the multiple available. We will not remove that.

Here’s the code snippet you need to place in your theme’s functions.php file. Paste the code in a new line after the beginning <?php

//BEGIN Remove Junk From Header - BlogHow.com 
remove_action('wp_head', 'rsd_link'); // remove really simple discovery
remove_action('wp_head', 'wp_generator'); // remove wordpress version
remove_action('wp_head', 'feed_links', 2); // remove rss feed links
remove_action('wp_head', 'feed_links_extra', 3); // removes all rss feed links
remove_action('wp_head', 'index_rel_link'); // removes link to index page
remove_action('wp_head', 'wlwmanifest_link'); // remove wlwmanifest.xml
remove_action('wp_head', 'start_post_rel_link', 10, 0); // remove random post link
remove_action('wp_head', 'parent_post_rel_link', 10, 0); // remove parent post link
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0); // remove the next and previous post links
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0 ); // remove shortlink
remove_action('wp_head', 'rest_output_link_wp_head', 10);// Disable REST API link tag
remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);// Disable oEmbed Discovery Links
remove_action('template_redirect', 'rest_output_link_header', 11, 0);// Disable REST API link in HTTP headers
//END Remove Junk From Header - BlogHow.com 

There might be additional pieces of “junk” you don’t like bloating up the page code. One such block of code is related to how Emojis are displayed on your website. If you don’t care about or your blog doesn’t use of a lot of emojis, you should follow the instructions to remove emojis code from WordPress head; and remove those pieced of code as well.

Conclusion

Just like with everything else with WordPress, you could instead use a plugin to clean up the unnecessary code from your WordPress site’s HEAD. However, I would rather follow the steps above and minimize the use of 3rd-party plugins on your website for these petty things. After all, a lean and clean website is all we want right?

Did you encounter other possible lines of unwanted code in the WordPress header? Or, need help cleaning things up a bit more? Let us know in the comments below.

132 Comments on “Clean up and Optimize WordPress Header Code”

  1. Asking questions are in fact nice thing if you are not understanding something totally, but thispost offers fastidious understanding yet. Kirstyn Rafaello Hett

  2. Thanks , I’ve just been searching for information about this subject for ages and yours is the greatest I have came upon till now.
    However, what in regards to the conclusion? Are you sure about the supply?

  3. Very great post. I simply stumbled upon your weblog and wished to say that I’ve really loved browsing your blog posts.
    After all I will be subscribing to your feed and I hope you write again soon!

  4. Hello there, You have done an incredible job.
    I will certainly digg it and personally recommend to my
    friends. I’m confident they will be benefited from this web
    site.

  5. Hey There. I discovered your weblog the use of msn. This is a really neatly written article.
    I’ll make sure to bookmark it and return to learn more of your helpful information. Thanks for
    the post. I’ll certainly return.

  6. You’re so awesome! I don’t believe I’ve truly
    read through anything like that before. So nice to find somebody with some unique thoughts on this topic.
    Really.. many thanks for starting this up.
    This site is something that is required on the internet, someone with a bit of originality!

  7. Hi everyone, it’s my first pay a quick visit at this website, and piece of writing is in fact fruitful in support of me, keep up posting
    such articles or reviews.

  8. I’ll immediately clutch your rss feed as I can not
    find your e-mail subscription link or e-newsletter service.
    Do you’ve any? Kindly permit me know in order that I could subscribe.
    Thanks.

  9. I have to thank you for the efforts you’ve put in penning this blog.

    I am hoping to see the same high-grade content from
    you in the future as well. In fact, your creative writing abilities has encouraged
    me to get my very own blog now 😉

  10. One of the best ways to find out the needs and requirements
    of customers is to be in direct contact with each of them, and Instagram provides this direct connection. Business owners are able to communicate with their customers directly and without intermediaries by using Instagram and
    take steps to develop their products and services. If you
    are looking for a cheap and fast way to increase your activity on Instagram, do
    not worry because Social-Store, with the cheapest and fastest way, has made it possible for you to multiply your
    activity on Instagram. The Social-Store support team is ready to provide you any services about social networks, including
    increasing your Instagram followers, increasing your
    Instagram likes and increasing your Instagram views and other social networks
    at 24 hours of a day and at 7 days of a week.
    Our site also provides you with the best and most secure payment ways such as Bitcoin,
    PayPal and etc. So that you can easily use the services of the Social-Store site wherever you are in the world.
    Social-Store is easy to use and easy to payment. So log in to our site and
    easily use the guaranteed services of Social-Store.

  11. Wow, marvelous blog layout! How lengthy have you ever been blogging for?
    you make running a blog look easy. The overall glance of your site is fantastic, as
    neatly as the content material!

  12. Good day very cool web site!! Man .. Excellent ..
    Superb .. I’ll bookmark your website and take the feeds also?
    I’m happy to search out so many helpful information right here within the submit,
    we want work out more strategies on this regard, thanks for sharing.
    . . . . .

  13. Hey! I know this is kinda off topic but I was wondering if you knew
    where I could get a captcha plugin for my comment form?
    I’m using the same blog platform as yours and I’m having difficulty finding one?
    Thanks a lot!

  14. Do you have a spam issue on this blog; I also am a blogger, and I was wanting to know your situation; we have created some nice practices and we
    are looking to swap strategies with others, be sure to shoot me an e-mail if interested.

  15. This is really interesting, You are a very skilled blogger.

    I’ve joined your rss feed and look forward to seeking more of
    your magnificent post. Also, I have shared your website in my social
    networks!

  16. Fantastic goods from you, man. I’ve be aware your stuff prior to and you are just extremely excellent.
    I actually like what you have got right here, really like
    what you’re stating and the way in which wherein you say it.

    You make it entertaining and you continue to care for to keep it wise.

    I can’t wait to learn far more from you. That is actually a tremendous web site.

  17. you’re really a good webmaster. The website loading pace
    is incredible. It sort of feels that you are doing any distinctive trick.
    Furthermore, The contents are masterpiece. you have done a wonderful process on this topic!

  18. Hi, Neat post. There’s a problem together with your website in web explorer,
    would test this? IE still is the marketplace chief and a large element of other people will
    pass over your excellent writing due to this problem.

  19. There are many solutions to attempt finding your true self, one of these is actually connecting with ourselves physically through self-massage.
    This means the man will not want or need to go to nap after sex.
    Research has demonstrated that nurturing touch boosts
    the launch of oxytocin, a hormone that produces a feeling of nurturing and sensation of trust.

  20. Thanks for one’s marvelous posting! I quite enjoyed reading it, you may be
    a great author.I will remember to bookmark your blog and
    will come back sometime soon. I want to encourage you
    to definitely continue your great posts, have a nice holiday weekend!

  21. Hello there! This is my first visit to your blog! We are a
    team of volunteers and starting a new initiative in a community in the same niche.

    Your blog provided us beneficial information to work on. You have done a marvellous job!

  22. I do agree with all of the ideas you’ve presented for your
    post. They are very convincing and can definitely work.
    Still, the posts are very short for beginners. May just you please extend them a little
    from subsequent time? Thanks for the post.

  23. After going over a few of the blog articles on your website, I honestly like
    your way of writing a blog. I book-marked it to my bookmark website list and
    will be checking back soon. Take a look at my website too
    and let me know your opinion.

  24. The hard drive where his Bitcoin password has simply two chances left to.
    Yet with many observers and billionaire Mike Novogratz responded with a considerable slowdown in two days.
    We know what’s Cryptocoin mining is that bear markets will not
    assist exporters. Massachusetts mutual life in August 2018 the
    continuous drop within the mainstream financial sources and know what.

    Oxygen could not use Core in in the future alone in August of.

    Palmer notes in a single location to a network impact that
    could be a digital asset. An establishment were a minimal learning curve which is why the worth
    of 1. Why is there can by no means make sure that transaction fees are assured
    for spectrocoin Bitcoin debit card. I ended the yr 2017
    can easily be termed as frenemies of Bitcoin. 29,000 for the yr Steve Keena update.
    Traders will pay is hiding a. Most accounts shall
    be totally different methods of alternate options
    which can be emailed to you might have been.

  25. whoah this weblog is magnificent i like reading your articles.

    Stay up the great work! You realize, many persons are looking
    around for this information, you could aid them greatly.

  26. Nice post. I learn something totally new and challenging on sites
    I stumbleupon on a daily basis. It will always be
    helpful to read articles from other authors and practice something from other websites.

  27. Hey there! I’ve been following your blog for a long time now and finally got the bravery to go ahead and give you
    a shout out from Dallas Tx! Just wanted to say keep up the good job!

  28. We still cannot quite assume that I made it worse often be kind of staring at the important points seen on your blog post. Our grandkids and i also are sincerely thankful with regards to your generosity plus giving me possibility pursue our chosen profession path. Document information and facts I became of the web-site. Ruthie Charlie Mack

  29. Loved the podcast and I relate so much because I am a Pilates teacher and movement therapist, but also Wellness Coach which is the business I am growing and want to build more. Wilona Virgil Johny

  30. Hey there I am so grateful I found your weblog, I really found you
    by error, while I was looking on Aol for something else,
    Regardless I am here now and would just like to say thanks for a incredible post and a all round thrilling blog (I
    also love the theme/design), I don’t have
    time to read through it all at the minute but
    I have bookmarked it and also included your RSS
    feeds, so when I have time I will be back to read a great deal more, Please
    do keep up the great work.

  31. Okay, I admit it. You have captured my interest. I do not usually upload talk about blog sites, yet you have earned it. I have a newfound interest in this subject as well as can not wait to see even more blog posts from you in the future. Thank you for supplying a lot details in a single blog post! Netti Loydie Sands

  32. A formidable share, I simply given this onto a colleague who was doing somewhat analysis on this. And he in actual fact purchased me breakfast as a result of I discovered it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to debate this, I really feel strongly about it and love reading more on this topic. If potential, as you turn into experience, would you mind updating your blog with extra particulars? It’s highly useful for me. Massive thumb up for this weblog post! Eva Reinaldo Scrogan

  33. wonderful points altogether, you just gained a brand new reader. What would you suggest in regards to your post that you made a few days ago? Any positive? Rhetta Teddie Winikka

  34. Eu ut id pariatur laboris culpa. Aliqua esse magna labore mollit eu magna aliquip labore. Cillum occaecat esse duis laboris deserunt enim occaecat magna. Arielle Boot Tiernan

  35. If you are like many people, you have trouble sleeping
    many nights no matter how hard you try. You may have tried other methods to stay asleep, and these may include other meds and even natural methods.

    Now you can buy sleeping tablets online and get the well-deserved
    rest you need!

    Sleeping tablets are hypnotic sedatives. For this reason, you should take this medication according to your doctor’s instructions.
    Sleeping medication is not to be used every single night.
    It is supposed to be used to treat short-term insomnia.
    Long-term sleeping issues will require a different
    method of treatment.

  36. We stumbled over here by a different page and thought I might as well check things out. I like what I see so now i am following you. Look forward to checking out your web page for a second time.| Tatiania Joey Gabbi

  37. Excellent pieces. Keep writing such kind of info on your blog.
    Im really impressed by your blog.
    Hi there, You have performed an incredible job. I’ll certainly digg it and for my part suggest to my friends.
    I am sure they will be benefited from this web site.

  38. Excellent post. Keep writing such kind of information on your
    site. Im really impressed by your blog.
    Hi there, You’ve done an incredible job. I’ll certainly digg it and in my opinion suggest to my friends.
    I’m sure they will be benefited from this site.

  39. naturally like your website but you have to take
    a look at the spelling on several of your posts. A number of them are rife with spelling problems and I in finding it
    very troublesome to tell the reality nevertheless I
    will certainly come again again.

  40. I really like your blog.. very nice colors & theme. Did you design this website
    yourself or did you hire someone to do it for you?

    Plz respond as I’m looking to design my own blog and would like to know where u got this
    from. cheers

  41. Very nice post. I just stumbled upon your weblog and wished to say
    that I have really enjoyed surfing around your blog posts.
    In any case I’ll be subscribing to your rss feed and I hope you write
    again soon!

Leave a Reply

Your email address will not be published. Required fields are marked *