Clean up wp_head output
- WordPress
WordPress injects several legacy meta tags and links into the <head> that most modern sites don’t need. Each one adds HTML weight and some trigger additional HTTP requests or DNS lookups.
<?php
/**
* Clean Up wp_head Output
*
* WordPress injects several meta tags and links into the <head> that most
* sites don't need: RSD link (for blog clients), WLW manifest (Windows Live
* Writer), shortlink, REST API discovery link, oEmbed discovery links, and
* adjacent post prefetch. Removing these reduces HTML size and eliminates
* unnecessary DNS lookups and HTTP requests.
*
* Usage: Add to functions.php.
*
* @category wordpress
* @language php
*
* @author Adame Dahmani https://adame.io
* @support Support my family project: https://adame.io/fundraiser
*/
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'wp_shortlink_wp_head' );
remove_action( 'wp_head', 'rest_output_link_wp_head' );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 );
remove_action( 'wp_head', 'feed_links_extra', 3 );What each line removes:
- RSD link — Really Simple Discovery, for XML-RPC blog clients nobody uses
- WLW manifest — Windows Live Writer support, discontinued in 2017
- Shortlink — the
?p=123URL, redundant if you use pretty permalinks - REST API link — discovery endpoint, unnecessary unless you expose a public API
- oEmbed — allows other sites to embed your posts, rarely needed
- Adjacent posts — prefetch hints for prev/next posts, wasteful on most themes
- Extra feed links — comment feeds, category feeds, tag feeds