This easy guide will help remove junk from your wordpress header and keep your code nice and clean. We all hate things that slow us down, so we take steps to eliminate them, if not, prevent them. Why don’t you think the same for your blog?
By default, WordPress adds a lot of built-in scripts and libraries on our blog. Have you ever checked out your WordPress header? If you have, then you might find many calls being made to import files, most of which we don’t even need.
How junk in your wp_head is slowing down your site?
Check out what are the disadvantages of including so many extra calls in your wp_head:
- Slow load time because browser is making so many requests
- If the size of those scripts is large, it will take even more time to download the file
- By chance if your file is not found on your server (or if the file resides on some other server and if it is down), it will result to 404 error, i.e. a bad link
- Since these calls are being made in the wp_head section, your visitors have to wait before any content is rendered, as scripts block parallel downloads
- It takes too much of extra space in your html file, the more lines of code, the more time your browser will take to load it
- Loading unwanted files will simply consume your server’s resources and memory which could have been used for other purposes
- In the end, you are the one who has to pay for it. Your visitor’s time is very precious, if you waste it, they will go elsewhere
I think by now you know, how bad, including junk in your life (oh sorry in your blog) is! So lets sit down and do a little research into what junk your wp_head is currently holding.
1. Feed Links: These links are the RSS feed links so that your users can subscribe to your blog easily. If you have already included a link to your RSS feed on your blog’s homepage and placed many call to action buttons on your blog for easy subscribe, then you can safely remove these feed links.
There are mainly 3 RSS links, the first one is your blog’s RSS feed, the second one is your post’s RSS feed, and the third one is the RSS link to your comments feed.
Feed links also include canonical urls, which are essential for search engines to determine the right url to your post page and generally these links should never be removed.
2. Really Simple Discovery (RSD)
This is a discovery service which uses XML-RPC calls to access and publish to your blog remotely like from a mobile app, or from any other blog publishing client like Windows Live Writer.
If you won’t be live blogging or using any other such services, then its ok to disable the call to RSD.
3. Windows Live Writer (WLW)
Windows Live Writer as mentioned earlier is a blog publishing application. If you are not going to use this application, then its best if you disable this.
4. Relational Links
These links are used by browsers, so that they can identify which is the previous post, next post, etc. Basically they use this information for easy navigation. You can remove these links safely.
5. Post Shortlinks
WordPress automatically creates shortlinks to your posts, so that the url of your post is smaller and takes up much less space when like say sharing your post to Twitter or Facebook, where the number of words in which you convey your message is important.
These links are unnecessary and can be easily removed.
6. WordPress Version Generator
These links should be specially removed to prevent any eavesdropping and to ensure your blog’s security. Hackers may use your wordpress version, to determine which exploits your blog is vulnerable to. Although wordpress is fully secure and there is no reason to get scared, but nonetheless you should never take a chance.
You can remove the wp generator link in your header safely.
How To Clean Up My WP_HEAD?
Here is a complete collection of all the links you wish to remove. If you want to remove calls to all these files, please include the code below into your functions.php file.
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'rsd_link' );
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
remove_action('wp_head', 'wp_generator' );
That’s it! Now click the Update File button and see your changes. Don’t forget to clear your caches before checking for any changes.
Although the pagespeed gained using this method is negligible, but it sure does help you reduce the number of requests made.
Did you know your WordPress theme also includes a call to jQuery script in your wp head? If you want to know the right way to include jquery in your theme, then refer to this tutorial.
Read: Remove the Default jQuery included in WordPress Easily
If you are looking to make your WordPress Site even faster, then refer to our full collection of PageSpeed tutorials or subscribe to our newsletter from the box below to never miss a single tutorial.
Thank You Drew!