Home
/
WordPress Tutorials
/
How to Limit WordPress Heartbeat To Lower Executions Numbers Tutorial

How to Limit WordPress Heartbeat To Lower Executions Numbers Tutorial

This tutorial covers the following topics:

WordPress 3.6 introduced the WordPress Heartbeat API – it allows your browser to communicate with the server when you’re logged into the WordPress admin panel. This functionality allows WordPress to handle things like showing other authors that a post is being edited by another user, plugins can use these script executions and show you notifications in real time, etc.

However, even though this is great functionality it may cause issues in certain cases. On different pages, Heartbeat makes checks on different period – on post edit, it makes it every 15 seconds, on your Dashboard – every minute, etc. Each “tick” generates a POST request which adds to the number of your executions and CPU time used.

This functionality uses the wp-admin/admin-ajax.php file to make AJAX calls. If you notice a significant amount of POST requests by that file, this means that you need to limit the work of Heartbeat or stop it completely.

How to Stop Heartbeat completely

In most cases, you can completely disable Heartbeat if you’re the only person working at any given time in your site and you know that you don’t have any important functionality that heavily relies on it to work properly.

To disable it, edit the functions.php file of your 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 should completely disable this functionality and it will no longer add to the executions number and CPU time used in your account.

An easier way to do that is simply to enable the WordPress Heartbeat Optimization in the Environment tab in in our SG Optimizer.

How to Limit Heartbeat

In order to limit the WordPress Heartbeat functionality, you can change the execution frequency for different locations. You can do that from the

Alternatively, you can choose the option Disable for the specific location from the menu, which should disable the use of the Heartbeat functionality on that location.

Share This Article