Remove dns-prefetch
from WordPress 4.9
Most people seem to have switched to statically generated blogs like Hugo by now, but I’ve been using WordPress for some 13 years and combined with WP-Super-Cache it’s been static for pretty much that entire time. There’s little point to putting in extra time and effort just for some extra nerd cred.
On the downside, every new 4.0+ release seems to add more cruft to the header. My functions.php
consists of an ever-growing list of remove_action
incantations. Here’s the latest addition, necessitated by WordPress 4.9.
// remove WP 4.9+ dns-prefetch nonsense
remove_action( 'wp_head', 'wp_resource_hints', 2 );
For those interested, here’s my full messy collection, including a few hints I commented out.
add_post_type_support( 'page', 'excerpt' );// See http://wordpress.mfields.org/2010/excerpts-for-pages-in-wordpress-3-0/
remove_action('wp_head', 'rsd_link');// Windows Live Writer? Ew!
remove_action('wp_head', 'wlwmanifest_link');// Windows Live Writer? Ew!
remove_action('wp_head', 'wp_generator');// No need to know my WP version quite that easily
// remove WP 4.2+ emoji nonsense
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
// remove WP 4.9+ dns-prefetch nonsense
remove_action( 'wp_head', 'wp_resource_hints', 2 );
// disable embeds nonsense; not even sure what it does
// Remove the REST API endpoint.
remove_action('rest_api_init', 'wp_oembed_register_route');
// Turn off oEmbed auto discovery.
// Don't filter oEmbed results.
remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10);
// Remove oEmbed discovery links.
remove_action('wp_head', 'wp_oembed_add_discovery_links');
// Remove oEmbed-specific JavaScript from the front-end and back-end.
remove_action('wp_head', 'wp_oembed_add_host_js');
// Jetpack
//remove_action('wp_head', 'shortlink_wp_head'); // Don't need wp.me shortlinks
// No jQuery! (als Jetpack
//if( !is_admin()){
//wp_deregister_script('jquery');
//wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"), false, '1.3.2');
//wp_enqueue_script('jquery');
//}
// remove OneAll Social script from regular page
remove_action ('wp_head', 'oa_social_login_add_javascripts');