How to Clean WordPress Sites for Speed Easily (Complete Guide)

Want to clean WordPress sites for speed? We have researched and found some effective ways to clean WordPress sites easily. Read along to learn and apply them on your site.

If you have been using WordPress for a while you might have noticed that your WordPress site does not stay the same always. You keep adding more content, installing new plugins for new functionalities, and changing themes again and again. All these activities add a lot of unnecessary things and have an impact on your website speed. If you don’t clean your WordPress site, your website will get slower and that would have an impact on your business eventually. 

The best way to address this issue is to clean WordPress site. We have faced similar situations before and found some ways to optimize our website. We are putting those ways here for you to speed up your WordPress site by cleaning unnecessary things that are causing slow page load issues. 

So, let’s begin!

How to Clean WordPress Sites for Speed

There are many things to clean especially when you are actively maintaining your site and making a lot of changes to it. In a race for Core Web Vitals, it is very important to make your website clean to pass it. 

As cleaning up a WordPress site requires technical knowledge, we will use plugins, and code, and follow some best practices to clean the WordPress site easily.

Remove Emoji Support in WordPress Site

You probably don’t use emojis on your WordPress site much. Even if you do, you would be willing to remove emoji support in the WordPress site as it loads extra libraries to your site and slows down your website a bit. 

Remove Emoji Support in WordPress Site

WordPress by default has this support (added in WordPress 4.2) in case you want to use them. But the issue with this is that it generates an additional HTTP request on the WordPress site to load the wp-emoji-release.min.js file on every single page. The fun fact is even with the emoji script disabled, you can still use emojis. They are generated/styled by the operating system instead.

Disable Emojis in WordPress With a Plugin

You can disable emojis in WordPress with a plugin. We are using the Perfmatters plugin to disable emojis in WordPress. The plugin easily disables emojis and optimizes WordPress sites in many other ways. 

Remove Emoji Support in WordPress Site

When Perfmatters is installed and activated, go to Dashboard > Settings > Perfmatters > General. You will find “Disable Emojis” in the first option. Enable the toggle to disable emojis on your WordPress site. The JS file for emojis will no longer load on every page from now on.

Disable Emoji in WordPress Site With Code

Alternatively, you can disable emojis on the WordPress site with PHP code as well if you don’t want to install any plugins for it. Add the following to your WordPress theme’s functions.php file. It is better to use a child theme in such cases.

/**
 * Disable the emoji's
 */
function disable_emojis() {
 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' );
 add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
 add_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 );
}
add_action( 'init', 'disable_emojis' );

/**
 * Filter function used to remove the tinymce emoji plugin.
 * 
 * @param array $plugins 
 * @return array Difference between the two arrays
 */
function disable_emojis_tinymce( $plugins ) {
 if ( is_array( $plugins ) ) {
 return array_diff( $plugins, array( 'wpemoji' ) );
 } else {
 return array();
 }
}

/**
 * Remove emoji CDN hostname from DNS prefetching hints.
 *
 * @param array $urls URLs to print for resource hints.
 * @param string $relation_type The relation type the URLs are printed for.
 * @return array Difference between the two arrays.
 */
function disable_emojis_remove_dns_prefetch( $urls, $relation_type ) {
 if ( 'dns-prefetch' == $relation_type ) {
 /** This filter is documented in wp-includes/formatting.php */
 $emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2/svg/' );

$urls = array_diff( $urls, array( $emoji_svg_url ) );
 }

return $urls;
}

PHP code to disable emojis. Code credit (Kinsta)

Note: Adding code to your file is risky if you are not familiar with code that much. We recommend you use to plugin for such kind of functionality. Perfmatters is a very lightweight performance plugin. 

Remove Dashicons Support on WordPress Site

Just like emojis, dashicons also adds an extra JavaSecript file (dashicons.min.css) that loads on every page of your WordPress site. Disabling dashicon support will help your site to load faster too. 

Disable Dashicons in WordPress With a Plugin

It is easy to disable dashicons with a WordPress plugin. We are using Perfmatters for this as before. While Perfmatters is installed and activated on your website,  go to Dashboard > Settings > Perfmatters > General.

Disable Dashicons in WordPress With a Plugin

You will find “Disable Dashicons” in the options. Enable the toggle to disable dash icons in your WordPress site.

Disable Embed Support on the WordPress Site

WordPress supports embeds from WordPress 4.4. This lets users embed YouTube videos, and many other resources on websites by pasting a URL. WordPress converts into an embed and provides a live preview in the visual editor because it adds a wp-embed.min.js file. 

Disable Embed Support on WordPress Site

But this file loads on every site causing your website to take extra time to load. You can disable embed support on the WordPress site.

Disable Embed in WordPress With a Plugin

Luckily, there are plugins to disable Embed in WordPress, we are using Perfmatters to do this here. go to Dashboard > Settings > Perfmatters > General. You will find “Disable Embed” in the options. Enable the toggle to disable Embed in your WordPress site.

Disable Embed in WordPress With Code

You can also disable Embed in WordPress with PHP code. Just paste the code below to your function.php file in your theme. 

function my_deregister_scripts(){

 wp_dequeue_script( 'wp-embed' );

}

add_action( 'wp_footer', 'my_deregister_scripts' );

Code credit: Kinsta

Note: Adding code to your file is risky if you are not familiar with code that much. We recommend you use to plugin for such kind of functionality.

Disable RSS Feeds and RSS Feed Links on the WordPress Site

People use the RSS feed to subscribe to new content that you post and also to feed into third-party reader applications. If you are not using the RSS feed for any such purpose, you can disable it for better performance. If you are using it for something like a podcast on a WordPress site you can keep it enabled. 

Disable RSS Feeds and RSS Feed Links in WordPress Site With a Plugin

While Perfmatters is installed and activated on your website,  go to Dashboard > Settings > Perfmatters > General. You will find “Disable RSS Feeds” and “Remove RSS Feed Links” in the options. Enable the toggle to disable both of these in your WordPress site.

Delete Post Revisions in WordPress

You can delete post revisions with Perfmatters too. While you have Perfmatters installed on your website, go to your dashboard > Settings > Perfmatters > Tools > Database.

Delete Post Revisions in WordPress

You will find the toggle “Post revisions” with the number of post revisions in your entire website. Now enable the toggle, click on the “Optimize Now” and “Save Changes” buttons at the bottom. You are done. You can also schedule optimization on a daily, weekly, and monthly basis.

Remove/Reduce Unused CSS

Reduce unused CSS” is a suggestion you may get while testing your website speed on Page Speed Insight. The good news is you can reduce unused CSS easily with Perfmatters.

Remove/Reduce Unused CSS

First of all, you need to find unused CSS, you can use Page Speed Insight to find unused CSS sources. If there is unused CSS on your website, you will see a warning and Google will ask you to reduce them. 

How to Reduce and Remove Unused CSS in WordPress

You can remove unused CSS in WordPress with Perfmatters automatically, Go to Dashboard > Settings > Perfmatters.

Remove/Reduce Unused CSS

Now go to “Assets” and find “Remove Unused CSS”, select Used CSS Method and Stylesheet Behavior from the available options, place the excluded stylesheet and stylesheet selectors in the boxes, and hit the Clear Used CSS button below. Now scroll down and click “Save Changes.” to make it work.

Clean WordPress Database by Removing Unnecessary Database Tables

You need to clean WordPress database to clean WordPress site. As your website grows, you add a lot of plugins and elements to your website. Those plugins and elements add some unnecessary tables to your WordPress database that you no longer need. You can easily remove those database tables to speed up your website.

Fortunately, Perfmatters can clean WordPress database easily. While Perfmatters is installed and activated on your website, go to Dashboard > Settings > Permatters > Tools, and click on Database

Clean WordPress Database by Removing Unnecessary Database Tables

You will find a lot of options to clean WordPress database here. You can remove post revisions, post-auto-drafts, trashed posts, spam comments, trashed comments, transients, and unnecessary database tables. Also, you can schedule database optimization on a weekly, daily, or monthly basis. Enable all the things you want to remove click “Optimize Now” then click “Save Changes” at the bottom. 

Manage Scripts on Your WordPress Site

Apart from disabling different scripts globally from the settings, you can disable scripts on the pages you want. Disable scripts globally may disable some elements where the scripts are necessary to load. You only need to disable scripts where those scripts aren’t necessary. 

Manage Scripts on Your WordPress Site

Perfmatters lets you do that too, you can manage scripts easily. Go to Dashboard > Settings > Permatters, click on “Assets” find “Manage Scripts” and enable it. Click on “Save Changes” at the bottom.

Manage Scripts on Your WordPress Site

While you are logged in to your website, you will find the “Manage Scripts” option while hovering on Perfmatters at the top bar of your website (admin bar). Go to the page you want to disable certain scripts, hover on Perfmatters click  “Manage Scripts” in the top admin bar, and now enable/disable the scripts you want. 

Cleaning up WordPress is a regular process. You need a plugin that can schedule such a cleanup process so that you don’t have to do it manually. Pefrmatters is a great performance optimization plugin that can help you clean WordPress site. Apart from these, this plugin has plenty of other options to optimize WordPress sites for speed.

Use the coupon code VIRFICE to get a 20% discount on Perfmatters plans exclusively available for Virifce fans.

In some cases, you can do them with free plugins or use code, but we have showcased the ways with Perfmatters, as this plugin alone handles all the cleaning up process and optimizes the WordPress site for speed. Using this plugin could save you from installing 10+ extra plugins on your WordPress site. That is why Virfice recommends Perfmatters. You can also get a 20% discount if you use the coupon code VIRFICE on your check exclusively available for Virifce fans.

Amie Suzan
Amie Suzan

As a seasoned WordPress technical writer with five years of experience, I am passionate about WordPress and web development. I also enjoy traveling, particularly solo trips, which allow me to explore new places and gain fresh perspectives.

Articles: 85

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *