How to Disable or Limit the WordPress Heartbeat API

HeartBeat API is a feature that allows web browsers communicate with servers. This communication between the browser and server happens via Ajax every 15 – 60 seconds.

The WordPress Heartbeat API is a great feature that provides real-time communication between the server and the browser. Only downside here is the high CPU usage.

If you’re on shared hosting plan, you need to be very careful as HeartBeat API can induce severe CPU usage spike. Some host might even shut your website down when you go over the limit.

Why You Should Disable or Limit HeartBeat API?

By default, WordPress sends AJAX requests every 15 seconds on post edit pages, and every 60 seconds on the dashboard.

If you leave your WordPress admin open for long periods, the AJAX requests from the API can pile up and generate high CPU usage. This might lead to server performance issues.

Hence it’s highly advisable to disable or limit the HeartBeat API requests.

How To Disable or Limit HeartBeat API?

  1. Download Heartbeat Control plugin from WordPress repository. Using Heartbeat Control plugin, you can easily choose to limit or completely stop the activity of the WordPress Heartbeat API.
  2. Install the plugin. If you’re beginner, read our step by step guide on plugin installation.
  3. Navigate to Settings » Heartbeat Control
  4. You can choose to disable or limit Heartbeat API on WordPress Dashboard, Frontend and Post Editor screen as shown below:-
    WordPress Heartbeat API
  5. After making necessary setting click “Save Changes”.

Disable Heartbeat API in WordPress Without a Plugin

If you want to disable HeartBeat API completely, add the below code to functions.php file

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

Alternatively, instead of adding it to functions.php file, you can use Code Snippet plugin to add the code to your website.

By limiting the HeartBeat API usage, you can efficiently use and manage your limited Server resources.

Hope you find the article helpful!

Credits

Leave a Comment