Limited offer: Get 50% OFF on monthly VPS Hosting plans!

How to Disable or to Limit WordPress Heartbeat

Estimated reading time: 1 min

WordPress Heartbeat API is a simple server polling API built in to WordPress, allowing near-real-time frontend updates.

 The API  is using the admin-ajax.php file to make AJAX calls. If you notice a significant amount of POST requests to that file, this means that you need to limit WordPress Heartbeat frequency or to completely disable it.

Sending excessive requests to admin-ajax.php can lead to high CPU usage.

How to disable WordPress Heartbeat

To completely disable it, go to the functions.php file of your WordPress theme and paste these lines right after the opening <?php tag:

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

This will completely disable this functionality and it will be no longer added to the total number of executions and CPU time used by your website.

How to limit  WordPress Heartbeat

In case you don’t want to disable it completely, you can simply limit its execution frequency. You can do this by using a plugin called Heartbeat Control.

Once you have installed the plugin you can decrease the Heartbeat frequency to 60 seconds or above. It is recommended to set Heartbeat locations to “Allow only on post edit pages”.

That’s a wrap!

You now know how to completely disable or to limit WordPress Heartbeat.

Was this article helpful?
No 0