How To Disable/Limit The WordPress Heartbeat API Manually Or With Plugins

Disable wordpress heartbeat admin ajax

The WordPress Heartbeat API should usually be disabled (or limited) because it consumes server resources.

However, WordPress Heartbeat is run on the frontend, backend, and editor. I would keep the backend heartbeat on, then limit the frontend/editor heartbeat by increasing the frequency to something like 60-120 seconds.

At the cost of server resources, the Heartbeat API uses /wp-admin/admin-ajax.php to run AJAX calls from the browser. In turn, it is able to show you real-time plugin notifications, when other users are editing a post (this sends a request every 15 seconds), and other unneeded features.

The easiest way to disable WordPress Heartbeat is to install the Heartbeat Control plugin, view the settings, and modify the Heartbeat interval in the dashboard, frontend, or post editor, or disable it completely. Other methods include adding a few lines of code to your functions.php file or using a plugin that already has an disable Heartbeat option like WP Rocket or LiteSpeed.

What Does The WordPress Heartbeat API Do?

  • Shows real-time plugin notifications
  • Shows when other users are editing a post
  • Shows when users are locked out for being idle
  • Creates periodic auto saves, drafts, and revisions
  • Shows real-time sales data when using eCommerce plugins

Important: always make sure you save your drafts when editing! If you disable the Heartbeat API and have auto drafts and post revisions turned off, you could risk losing all your hard work.

 

1. Install The Heartbeat Control Plugin

The easiest way to disable the WordPress Heartbeat API is with the Heartbeat Control plugin. Once installed, go to the General Settings and you can disable Heartbeat in the WordPress dashboard, frontend, and the post editor. Ideally, it is recommend you disable it everywhere.

Disable heartbeat

If you don’t want to disable Heartbeat and limit it instead, you can modify Heartbeat and choose your own intervals. By default, the WordPress heart beats once every 15 seconds.

 

2. Manually Disable The WordPress Heartbeat API

To disable the WordPress Heartbeat API without a plugin, go to Appearance > Theme Editor, then edit the functions.php file of your theme. Next, paste the code right after the <?php tag:

Disable wordpress heartbeat

add_action( 'init', 'stop_heartbeat', 1 );
function stop_heartbeat() {
wp_deregister_script('heartbeat');
}

 

3. Disable Heartbeat With WP Rocket

If you’re already using WP Rocket, they also have an option to disable or limit Heartbeat. One major advantage of WP Rocket is that it comes with more built-in speed optimizations than other cache plugins. This not only means less plugins running on your WordPress site, but better speed optimizations and GTmetrix scores. That’s why it’s usually #1 in Facebook polls.

Wp rocket heartbeat control settings

 

5. Disable Heartbeat With LiteSpeed Cache

If you’re using the LiteSpeed Cache plugin, they also have an option to disable WordPress heartbeat in Toolbox → Heartbeat. You can edit the frontend, backend, and editor heartbeat.

Litespeed cache heartbeat settings

 

6. Disable Heartbeat With Perfmatters

You can also use the Perfmatters Plugin (by Kinsta) to disable the WordPress Heartbeat. This plugin also lets you selectively disable plugins, scripts, and styles from loading on certain pages, limit post revisions, and disable many unnecessary things in the WordPress admin. I use it on my own website and like to say “it takes care of the last 10% of your WordPress speed.”

Permatters heartbeat control settings

 

What’s Next?

I have some great resources on WordPress speed optimization:

And many more which you can find below.

Hope this was helpful! Comment if you need any help at all.

Cheers,
Tom

You Might Also Like:

8 thoughts on “How To Disable/Limit The WordPress Heartbeat API Manually Or With Plugins”

  1. Hey Tom,

    Many thanks for this great article and your amazing website, it’s a great resource. Should we be worried about the warning from WPROCKET about disabling it …

    “Reducing activity will change Heartbeat frequency from one hit each minute to one hit every 2 minutes. Disabling Heartbeat entirely may break plugins and themes using this API.”

    Thanks
    Seán

    Reply
  2. Hi Tom, my current settings are reduce activity for all. We have been getting huge spikes with admin-ajax.php on our servers and have not been able to locate where the spike is coming from our wordpress currently causing a lag load on our site. We tried disabling plugins, themes and still cant find the issue. There is no admin-ajax on waterfall either while checking. Do you have any recommendations on how we can find this problem?. It is an ecommerce site. Should we be disabling any of these functions in Wp rocket to help?

    Reply
  3. You have a new fan, Tom! :)

    I find your site very, very helpful, and I like the way you are serving the info – not all of us are pro.

    Not only that but you’ve won me with your bio, too, so that’s it, I stay! :)

    I believe that I have what to learn here.

    Reply
    • Haha thanks Alexandra! I spent a lot of time on the bio and did it out of pure enjoyment. I have a lot of updating to do on my articles but I’m constantly working on it. If you have any questions just lmk. I appreciate you :)

      Reply
  4. Tom, thanks a lot! I suffered a lot from this feature with my hosting, the site constantly started giving 503 errors. By disabling the function, I overcame this. Thanks for the advice, everything works !!!

    Reply

Leave a Comment