WordPress Heartbeat should be disabled (or limited) since it increases CPU usage.
It runs in the frontend, backend, and post editor by default. In general, it’s best to disable WordPress Heartbeat in the frontend/backend, then limit the post editor to 60-120 seconds.
At the cost of server resources, Heartbeat uses /wp-admin/admin-ajax.php to run AJAX calls from the browser. It’s useful for showing you real-time plugin notifications, when other users are editing a post (which creates a request every 15s), and other usually unnecessary features.
Most caching/optimization plugins have a setting to disable/limit Heartbeat including Perfmatters, WP Rocket, and LiteSpeed Cache. If your plugins don’t have a setting, use the Heartbeat Control plugin or disable it manually by adding a few lines of code to functions.php.
What Does WordPress Heartbeat Do?
- Show real-time plugin notifications
- Show when other users are editing a post
- Show when users are locked out for being idle
- Create periodic auto saves, drafts, and revisions
- Show real-time sales data when using eCommerce plugins
Important: always make sure you save your drafts when editing! If you disable the Heartbeat API and have auto drafts and post revisions turned off, you could risk losing all your hard work.
1. Install The Heartbeat Control Plugin
The easiest way to disable the WordPress Heartbeat API is with the Heartbeat Control plugin. Once installed, go to the General Settings and disable Heartbeat in the WordPress dashboard, frontend, and limit it in the post editor. I limited the post editor to 120s, but you can increase this even more if it’s just you working on your site – or you want to save even more resources.
2. Manually Disable WordPress Heartbeat
To disable the WordPress Heartbeat API without a plugin, go to Appearance → Theme Editor, then edit the functions.php file of your theme. Next, paste the code right after the <?php tag:
add_action( 'init', 'stop_heartbeat', 1 );
function stop_heartbeat() {
wp_deregister_script('heartbeat');
}
3. Disable Heartbeat In WP Rocket
If you’re using WP Rocket, there’s a setting to disable or limit Heartbeat.
Reduce activity changes the interval from 1 hit per minute to one hit per 2 minutes.
The Heartbeat Control plugin was actually developed by WP Rocket. However, I’m not a fan of their cache plugin and would argue FlyingPress and LSC are better. But that’s a different story.
4. Disable Heartbeat In LiteSpeed Cache
If you’re using the LiteSpeed Cache plugin, they also have an option to disable WordPress heartbeat in Toolbox → Heartbeat. You can edit the frontend, backend, and editor heartbeat.
5. Disable Heartbeat In Perfmatters
Perfmatters recommends the only allow when editing posts/pages option. Most people know Perfmatters for the script manager which disables CSS, JS, or entire plugins on pages they’re not used. However, Perfmatters has several other features which “fill in” lacking optimizations not found in other cache plugins (specifically WP Rocket, SG Optimizer, and free cache plugins).
What does WordPress Heartbeat do?
WordPress Heartbeat lets you see real-time plugin notifications, when other users are editing a post, and other functions when editing your website.
Why should I disable WordPress Heartbeat?
Saving server resources is the main reason to disable WordPress Heartbeat, since it generates requests to your server.
Should I disable WordPress heartbeat in the frontend, backend, and post editor?
It's generally recommended to disable Heartbeat in the frontend/backend, then limit it in the post editor (to something like 120 seconds).
Hope this was helpful! Comment if you need any help.
Cheers,
Tom
Hey Tom,
Many thanks for this great article and your amazing website, it’s a great resource. Should we be worried about the warning from WPROCKET about disabling it …
“Reducing activity will change Heartbeat frequency from one hit each minute to one hit every 2 minutes. Disabling Heartbeat entirely may break plugins and themes using this API.”
Thanks
Seán
Always good to test but heartbeat is usually only needed in the post editor.
Hi Tom, my current settings are reduce activity for all. We have been getting huge spikes with admin-ajax.php on our servers and have not been able to locate where the spike is coming from our wordpress currently causing a lag load on our site. We tried disabling plugins, themes and still cant find the issue. There is no admin-ajax on waterfall either while checking. Do you have any recommendations on how we can find this problem?. It is an ecommerce site. Should we be disabling any of these functions in Wp rocket to help?
Hi Rebecca, sorry for the delay.
Yes, WP Rocket’s preloading and automatic cache clearing can increase CPU usage especially if you’re triggering actions that constantly do this. You should ideally only preload important sitemap URLs (not the full sitemap) and setup a cron job to control these. See here: https://onlinemediamasters.com/reduce-cpu-usage-wordpress/#preloading
You have a new fan, Tom! :)
I find your site very, very helpful, and I like the way you are serving the info – not all of us are pro.
Not only that but you’ve won me with your bio, too, so that’s it, I stay! :)
I believe that I have what to learn here.
Haha thanks Alexandra! I spent a lot of time on the bio and did it out of pure enjoyment. I have a lot of updating to do on my articles but I’m constantly working on it. If you have any questions just lmk. I appreciate you :)
Tom, thanks a lot! I suffered a lot from this feature with my hosting, the site constantly started giving 503 errors. By disabling the function, I overcame this. Thanks for the advice, everything works !!!
It’s great when something is an easy fix! Yes 503 errors… I have an article on reducing CPU which can help but sounds like you should be good :)