Skip to content

Instantly share code, notes, and snippets.

@ianpegg
Last active March 9, 2026 17:28
Show Gist options
  • Select an option

  • Save ianpegg/53842447a5016ad5d3eac073dd2390d5 to your computer and use it in GitHub Desktop.

Select an option

Save ianpegg/53842447a5016ad5d3eac073dd2390d5 to your computer and use it in GitHub Desktop.
A lightweight way to improve performance by removing elements of WP core that we don't need.
<?php
/**
* Plugin Name: eggMUP: Performance
* Plugin URI: https://gist.github.com/ianpegg/53842447a5016ad5d3eac073dd2390d5
* Description: Optimise WP for performance by removing things we don't need.
* Version: 1.0.1
* Author: Ian Pegg
* Author URI: https://eggcupwebdesign.com
* php version 8.3.1
*
* @category Must_Use_Plugin
* @package WordPress_Plugin
* @author Ian Pegg <hello@eggcupweb.com>
* @license GNU/GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
* @link https://eggcupwebdesign.com
*/
namespace EggCup\MUP\Performance;
if (!defined('ABSPATH')) {
exit;
}
/**
* Removes all the cruft that WP core adds to the <head>.
*
* @return void
*/
add_action('init', function () {
add_filter('the_generator', '__return_false');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10);
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'wp_shortlink_wp_head', 10);
remove_action('wp_head', 'wp_oembed_add_discovery_links');
remove_action('wp_head', 'wp_oembed_add_host_js');
remove_action('wp_head', 'rest_output_link_wp_head', 10);
add_filter('use_default_gallery_style', '__return_false');
add_filter('show_recent_comments_widget_style', '__return_false');
});
/**
* Strips out emoji scripts as most browsers support emojis natively
* these days anyway.
*
* @return void
*/
add_action('init', function () {
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_filter('the_content_feed', 'wp_staticize_emoji');
remove_filter('comment_text_rss', 'wp_staticize_emoji');
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
if (!is_admin()) {
add_filter('emoji_svg_url', '__return_false');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment