WordPress, as a powerful content management system, offers a myriad of functionalities out of the box. However, not all of these functionalities are necessary for every website, and sometimes, they can actually slow down your site’s performance. One way to optimize your WordPress website is by removing unnecessary actions. In this guide, we’ll walk through various actions that can be removed to streamline your site’s performance.

1. Removing REST API Link Headers

PHP
remove_action( 'template_redirect', 'rest_output_link_header', 11 );

The REST API link header provides information about the REST API endpoints. However, if your site doesn’t heavily rely on REST API functionality, removing this action can reduce unnecessary overhead.

2. Disabling Shortlink Headers

PHP
remove_action( 'template_redirect', 'wp_shortlink_header', 11 );

Shortlink headers provide short URLs for posts and pages. If you’re not using shortlinks, removing this action can eliminate unnecessary processing during template redirection.

3. Disabling oEmbed Endpoints

PHP
remove_action( 'rest_api_init', 'wp_oembed_register_route' );

WordPress oEmbed allows embedding content from other sites. If your site doesn’t utilize oEmbed functionality, removing this action can improve performance by disabling the registration of oEmbed routes.

4. Removing Various Meta Tags

PHP
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', 'rsd_link' );
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 );
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'wp_robots', 1 );

These actions remove various meta tags such as REST output links, oEmbed discovery links, Really Simple Discovery (RSD) links, feed links, Windows Live Writer links, adjacent posts links, WordPress generator tag, and WordPress robots tag. Removing these can declutter your site’s HTML output and improve loading times.

5. Disabling Emoji Scripts and Styles

PHP
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' );

If you don’t use emojis on your site, removing these actions can prevent unnecessary scripts and styles from loading, thus enhancing performance.

By selectively removing these actions based on your site’s requirements, you can optimize its performance and provide a better user experience. However, always remember to test thoroughly after making such changes to ensure everything functions as expected.