WordPress Heartbeat API is a great feature and opens the door to some great possibilities for plugin developers. However in some cases, it can increase your CPU usage and slow down your website. In this article, we will show you how to limit Heartbeat API in WordPress or even completely stop it.
Introduced in WordPress 3.6, Heartbeat API allows your browser to communicate with the server using AJAX calls when you are logged into WordPress admin area. This allows WordPress to show other authors that a post is being edited by another user and enable plugin developers to show you notifications in real-time.
This sounds great but if you have too many requests, then your server will slow down. Letβs take a look at how to limit or completely stop WordPress Heartbeat API.
First thing you need to do is install and activate the Heartbeat Control plugin. Upon activation, you need to visit Settings Β» Heartbeat Control to configure the plugin.
From the βControl heartbeat locationsβ option, you can select where you want to control heartbeat settings. You can disable it on dashboard, allow it on post edit pages, or completely disable it everywhere.
The next option allows you to control the frequency of heartbeat. By default, heartbeat makes a post call every 15 seconds on post edit pages, and every minute on the dashboard. You can choose a higher frequency.
Click on the save changes button to store your settings. Thatβs all you have successfully limited heartbeat API calls on your site.
Disable Heartbeat API in WordPress Without a Plugin
If you are a single user on your site, and you are sure that you will not be needing any features made possible by the API, then you can disable it. You can use heartbeat control plugin, we mentioned above, or you can simply copy and paste this code snippet into your themeβs functions.php file or in a site-specific plugin.
1 2 3 4 | add_action( 'init' , 'stop_heartbeat' , 1 ); function stop_heartbeat() { wp_deregister_script( 'heartbeat' ); } |
We hope this article helped you learn how to limit heartbeat API in WordPress. You may also want to checkout these tips and hacks to protect WordPress admin area.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.