Automation is the market demand. WordPress started thinking about sophisticated automation between web browsers and servers long ago.
With WordPress 3.6, HeartBeat API was introduced to better communicate between web browsers and servers.
Heartbeat API brought a much-needed opportunity for plugin developers to quickly connect to a web server using the API.
It made their life much easier as they no longer needed to write thousands of lines of code to connect to web servers. Instead, they have to use heartbeat API to connect.
Though heartbeat API has many useful features, it may also slow down your website. This is due to the excessive API calls that the heartbeat API makes to a web server.
Slow-loading websites lead to poor user experience and a high bounce rate. Limiting the heartbeat API is necessary if you want to speed up your website.
So, in this article, we will talk about How to limit Heartbeat API in WordPress.
Table of Contents
What Is Heartbeat API
As the name suggests, Heartbeat API is a communication protocol between web browsers and servers. It uses AJAX calls to communicate.
If so many plugins are using heartbeat API, a huge number of AJAX calls will be made to the web server. This, in turn, slows down the website’s loading speed.
You might be wondering, when this heartbeat API has so many issues, then why do we need it?
Heartbeat API has some exciting features that many end users may find very useful.
Below are a couple of features that heartbeat API offers.
- Enables post-revision features in the WordPress dashboard
- Autosave posts
- Lock post-editing for a multi-authored blog
- Show all notifications in the WordPress dashboard
- Shows real-time sales data for Woo Commerce stores
How Heartbeat API works
Heartbeat API uses the admin-ajax.php file located under “/wp-admin/admin-ajax.php “to send AJAX calls to communicate with the web server.
At times, when many plugins use the heartbeat API, it stops responding, and you will be presented with a CPU overutilization error.
The heartbeat API triggers pulses every 15 seconds to ensure a connection between the web server and the web browser.
Each pulse executes one PHP script and thus makes one CPU call to the web server. WordPress throws a connection error if the pulse takes more than 30 seconds to get a response.
How To Monitor Heartbeat API
There is no option in the WordPress dashboard to check the uses of Heartbeat API. You can ask your web host to send a report of CPU utilization statistics. You can also use the statistics data from your C-Panel dashboard.
The image below shows a snapshot of a C Panel.

GTMetrix waterfall chart is the simplest way to check which plugins or files might use heartbeat API.
Sometimes, you may not see any plugin name, and you may only see some codes. Searching with those codes on Google may help you determine which plugin uses the API and fix it accordingly.

You may have noticed that ta_link_fixer uses the heartbeat API in the above waterfall chart. A quick googling discovered that this is caused by an option in the plugin ” Thirsty Affiliates“.
The heartbeat API issue disappeared when I unchecked the option and ran the GTMetrix analysis. I also noticed that my website loads faster once the heartbeat API is stopped. You can notice the difference in fully loaded time.
The below image the improvement in speed after I stopped the heartbeat API.

Implications of using Heartbeat API
Heartbeat API not only slows down your website but can also have more severe implications if you use shared hosting.
Typically, all shared hosting allows a finite CPU utilization, although they say they offer unlimited bandwidth.
Once you hover near your account’s maximum CPU utilization, the web host will send a warning email.
If you don’t take measures to reduce CPU utilization, they may temporarily suspend your hosting account.
A repeated temporary suspension will lead to a permanent suspension without any refunds. Hosting companies follow this practice to ensure every account gets equal resources in a shared host environment.
How to Disable WordPress Heartbeat API
The best way to limit Heartbeat API in WordPress is to delete all plugins that use Heartbeat API.
Sometimes it is not possible as you will be losing a lot of functionalities. In this case, you may choose to limit the frequency of API calls. You can limit API calls using the following methods.
- Using a plugin
- Adding a few lines of code in the function.php file
Disable WordPress Heartbeat API Using A Plugin
Using a plugin to limit the heartbeat API in WordPress is advisable. If you are not tech-savvy, using a plugin can save you from unnecessary issues.
Perfmatters is the best for enabling or limiting Heartbeat API among all those plugins.
Below are the steps that show how to do that.
1. Go To Perfmatters Plugin Setting
You must log in to the WordPress dashboard-> Setting-> Perfmatter to access the Perfmatters setting.

2. Go To the General Tab
Under settings, go to the “General” tab.

3. Access The Heartbeat Tab
Scroll down to the Heartbeat API option in the general tab.

Under the ” Disable Heartbeat” option, choose from the following option.

If you choose the option “ Disable Everywhere, ” you don’t have to set the frequency. If not, you can choose the frequency here.

Ideally, you can keep the option ” Only Allow When Editing Posts/ Pages” checked unless you feel your dashboard is slow.
That will ensure you can still access features like Auto-Save, Post revisions, Live statistics, etc. If you don’t need those features, you can select ” Disable Everywhere.” That will disable the heartbeat API on the backend and the front end.
If you want to use WP Rocket to disable the heartbeat API, then you can refer to the following video.
Disable WordPress Heartbeat API Without A Plugin
If you don’t want to install a plugin to control the heartbeat API, you can use the following codes to stop the API from making any calls.
If you use a child theme, you can add these lines of code in the funtion.php file available in the child theme folder.
It is always advisable to back up the file before making any changes so that you can retrieve it in case something goes wrong.
add_action( 'init', 'stop_heartbeat', 1 );
function stop_heartbeat() {
wp_deregister_script('heartbeat');
}
Conclusion: How to Limit WordPress HeartBeat API
If you are a solo blogger and no other authors are accessing your WordPress dashboard, then it is high time to disable the heartbeat API.
That will save your bandwidth, and the website will be much faster. You can even disable the heartbeat API in the post editor.
I know you will miss the auto-save and post-revision features if you do so. However, you can always write your article in Google Docs and paste it into your WordPress post editor when it’s done.
You may know that every second’s delay costs you about 40% of the visitors. Do you want to lose those visitors just because of Heartbeat API?
I believe now you know How to disable heartbeat API in WordPress. So go ahead and disable heartbeat API and enjoy a faster-loading website.
That’s all I have in this article. Do you see any other issues which are affecting your website speed? If so, please write in the comment section, and I will try to offer a solution.
FAQ | Limit Heartbeat API
What Is Heartbeat API In WordPress?
Heartbeat API is a communication protocol for WordPress that communicates between a web browser and a web server.
With Heartbeat API, WordPress developers do not need to write hundreds of lines of code to create a communication protocol between a web server and a web browser. Instead, they can use the Heartbeat API
Heartbeat API uses AJAX calls to communicate.
How To Disable Heartbeat API?
You can disable the Heartbeat API by adding the following piece of code in the function.php file located in the child theme directory.
add_action( ‘init’, ‘stop_heartbeat’, 1 ); function stop_heartbeat() { wp_deregister_script(‘heartbeat’); }