How to Disable or to Limit WordPress Heartbeat Print

  • 0

WordPress Heartbeat API is a simple server polling API built into 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.

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.


Was this answer helpful?

« Back