How to Get Rid of Unwanted Junk from WordPress Header

wp-wordpress-junk
Learn how to remove junk from WordPress

By default, WordPress adds lots of unwanted links into head section of blog.

This guide will help you remove junk from WordPress HTML header.

Remove Blog and Comments Feed from WordPress Head

Stop the Bad Habit of putting custom code snippets in functions.php file.

Follow Good Habit and place the below code in WordPress Blog Specific Plugin.

// Remove Blog and Comments Feed Link from WordPress Head
remove_action( 'wp_head', 'feed_links', 2 );

kinsta managed wordpress hosting
Pay Yearly, Get 2 Months FREE

Remove RSD Link from WordPress Head

Remove EditURI link i.e. xmlrpc.php?rsd from your site.

Do this only if you don’t edit your WordPress blog from external services.

It will disable Really Simple Discovery endpoint link i.e. EditURI link.

// Remove RSD Link from WordPress head
remove_action('wp_head', 'rsd_link');

Remove Manifest Link from WordPress Head

It will remove wlwmanifest.xml link from WordPress document head.

You won’t be able to edit your blog through Windows Live Writer.

// Remove Manifest Link from WordPress Head
// Disable Windows Live Writer Support
remove_action('wp_head', 'wlwmanifest_link');

Remove Next Prev Links from WordPress Head

// Remove Next Previous Links from WordPress Head
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);

Remove Emoji Style and Script from WordPress Head

// Remove Emoji Style and Script from WordPress Head
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );

Remove DNS Prefetch from WordPress Head (Frontend)

It will remove dns-prefetch s.w.org link.

convertkit email marketing tool
14 Days Free Trial

// Remove dns-prefetch Link from WordPress Head (Frontend)
remove_action( 'wp_head', 'wp_resource_hints', 2 );

Remove Oembed Links from WordPress Head

It will remove two links:

  • application/json+oembed link in the format wp-json/oembed/1.0/embed?url=your-blog-url
  • text/xml+oembed link in the format wp-json/oembed/1.0/embed?url=your-blog-url&format=xml

// Remove oembed Post Links from WordPress Head (Frontend)
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );

Remove WP Json Rest API Link from WordPress Head

It will remove link rel api.w.org with your-blog-url ending with /wp-json.

// Remove WP Json Rest Api link from WordPress Head (Frontend)
remove_action( 'wp_head', 'rest_output_link_wp_head');

Remove Default jQuery from WordPress Head (Frontend)

It will remove two jQuery links:

  • jquery.js?ver=1.12.4
  • jquery-migrate.min.js?ver=1.4.1

// Remove Default jQuery from WordPress Head (Frontend)
function remove_default_scripts( ){
      See WordPress Consultant at the end of article.
}
add_action( 'wp_enqueue_scripts', 'remove_default_scripts');

Remove Dashicons from WordPress Head (Frontend)

It will remove dashicons.min.css from your blog.

// Remove Dashicons from WordPress Head (Frontend)
function remove_default_scripts2( ){
      wp_deregister_style( 'dashicons' );
}
add_action( 'wp_enqueue_scripts', 'remove_default_scripts2');

Live Chat Software
Improve Sales & Service with Chat & Ticketing System

Remove Html5shivmin.js from WordPress Head (Frontend)

This code will remove html5shiv.js from your site.

// Remove html5shivmin.js from WordPress Head (Frontend)
function remove_default_scripts3( ){
      wp_deregister_script( 'html5shiv' );
}
add_action( 'wp_enqueue_scripts', 'remove_default_scripts3');

WordPress Consultant

Contact me if you want to properly remove default jQuery from WordPress Frontend without affecting the backend.