{"id":17519,"date":"2019-05-03T11:21:38","date_gmt":"2019-05-03T11:21:38","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=17519"},"modified":"2025-12-02T15:35:23","modified_gmt":"2025-12-02T15:35:23","slug":"wordpress-heartbeat","status":"publish","type":"post","link":"\/ca\/tutorials\/wordpress-heartbeat\/","title":{"rendered":"What is WordPress Heartbeat API and how to manage it"},"content":{"rendered":"<p>In 2013, WordPress introduced Heartbeat API &ndash; a feature that allows your browser to communicate automatically with the server. However, there are a couple of drawbacks to this feature.<\/p><p>If you use a shared hosting plan, you need to take a closer look at the <a href=\"https:\/\/www.freecodecamp.org\/news\/what-is-cpu-meaning-definition-and-what-cpu-stands-for\/\" target=\"_blank\" rel=\"noreferrer noopener\">CPU<\/a> usage of your server, because some hosting companies might suspend your account when you exceed the limit.<\/p><p>Here, we&rsquo;ll talk about why WordPress Heartbeat API is the usual suspect that causes the issue.<\/p><p class=\"has-text-align-center\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Mega-WordPress-Cheat-EN.pdf\" target=\"_blank\" rel=\"noopener\">Download all-in-one WordPress cheat sheet<\/a><\/p><h2 class=\"wp-block-heading\" id=\"h-what-is-wordpress-heartbeat-api\">What is WordPress Heartbeat API?<\/h2><p>WordPress Heartbeat API provides a communication protocol, using <a href=\"\/ca\/tutorials\/what-is-ajax\/\" target=\"_blank\" rel=\"noreferrer noopener\">AJAX<\/a> calls, between the browser and the server.<\/p><p>As the name implies, the API will send continuous pulses and trigger events (or callbacks) upon receiving data. This function helps sync all the data between the server and the WordPress dashboard.<\/p><p>The idea behind Heartbeat API is quite compelling. For example, when you create\/edit a post from the editor, it provides a function to autosave the post periodically.<\/p><p>In a collaborative WordPress site, it has a post-locking function to prevent you from editing a post that&rsquo;s being worked on by another user. If you use an eCommerce plugin, this API will also help to display sales on your site.<\/p><h2 class=\"wp-block-heading\" id=\"h-why-limit-wordpress-heartbeat-api\">Why limit WordPress Heartbeat API?<\/h2><p>While having an autosave function and real-time data notification features can be beneficial, they can also be harmful in a specific situation.<\/p><p>Heartbeat API sends AJAX requests (POST requests) using the <strong>\/wp-admin\/admin-ajax.php<\/strong> file. Each request that executes a PHP file equals CPU time on the server.<\/p><p>This can cause a large number of requests to be sent to the hosting server, which results in high CPU utilization.<\/p><p>As we noted earlier, this can be a problem for a webmaster with a shared hosting plan. As you reach your quota limit, high CPU usage can eventually lead to account suspension. So be sure to check <a href=\"\/ca\/tutorials\/how-to-fix-admin-ajax-file\/\" target=\"_blank\" rel=\"noreferrer noopener\">how to fix spikes in your admin ajax file<\/a>. <\/p><h2 class=\"wp-block-heading\" id=\"h-things-to-consider-before-stopping-heartbeat-api\">Things to consider before stopping Heartbeat API<\/h2><p>If you&rsquo;re thinking of completely stopping Heartbeat API, you need to think twice. It&rsquo;s not because you can&rsquo;t do that, it&rsquo;s just not practical.<\/p><p>Without WordPress Heartbeat API, all the changes you made in the post will be lost should you ever forget to click the <strong>Save Draft<\/strong> button. And you will no longer have access to the <a href=\"https:\/\/wordpress.org\/support\/article\/revisions\/#description\" target=\"_blank\" rel=\"noreferrer noopener\">Revisions feature in WordPress<\/a>.<\/p><p>If you install <a href=\"\/ca\/tutorials\/best-wordpress-plugins\/\" target=\"_blank\" rel=\"noreferrer noopener\">WordPress plugins<\/a> that use Heartbeat API, you also can&rsquo;t display the real-time notifications and information features on your site.<\/p><p>But if you&rsquo;re working alone and all of these functions do not matter to you, you can then proceed to stop WordPress Heartbeat API.<\/p><p>Otherwise, you might consider controlling the API instead.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-completely-stop-heartbeat-api\">How to completely stop Heartbeat API?<\/h2><p>You can stop Heartbeat API by adding this code snippet to your active theme&rsquo;s <strong>functions.php<\/strong> file.<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">add_action( 'init', 'stop_heartbeat', 1 );\nfunction stop_heartbeat() {\nwp_deregister_script('heartbeat');\n}<\/pre><p>Remember, you should do this if you&rsquo;re the only person working with the website, and you don&rsquo;t need to install additional plugins that use this API.<\/p><div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"738\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/05\/edit-the-functions-php-file.png\/public\" alt=\"Edit the function.php file to disable WordPress heartbeat\" class=\"wp-image-17524\"  sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div><p>From your WordPress Dashboard, go to <strong>Appearance -&gt; Theme Editor<\/strong>. Make sure you&rsquo;re editing the active theme of your site. Click <strong>Theme Functions (functions.php)<\/strong> from the right-hand navigation menu. Paste the code snippet above right after the opening <strong>&lt;?php<\/strong> tag and click <strong>Update<\/strong>.<\/p><p>That&rsquo;s it, and now you&rsquo;ve successfully disabled WordPress Heartbeat API on your site.<\/p><figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-wordpress-hosting\" href=\"\/ca\/wordpress-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"2048\" height=\"600\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2024\/06\/New-WP_in-text-banner.png\/w=1024,h=1024,fit=scale-down\" alt=\"\" class=\"wp-image-111781\"  sizes=\"auto, (max-width: 2048px) 100vw, 2048px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>You&rsquo;ve learned about <a href=\"\/ca\/tutorials\/what-is-wordpress\/\">WordPress<\/a> Heartbeat API and the functionality it gives to your site. Although it&rsquo;s undoubtedly beneficial, in a shared hosting environment, it can cause quite a problem should you not handle it well.<\/p><p>To reduce the CPU usage on your server, you can either control the API or completely disable it. Also, you can do it by adding code to the <strong>functions.php<\/strong> file.<\/p><p>        <div class=\"protip\">\n            <div class=\"protip__heading\">\n                <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path d=\"M1.49234 23.5024C1.23229 23.5024 0.972242 23.4024 0.782206 23.2123C0.562165 22.9923 0.452144 22.6822 0.502153 22.3722C0.562165 21.9221 1.14227 17.9113 3.00262 16.351C3.63274 15.8209 4.43289 15.5509 5.26305 15.5609C6.09321 15.5909 6.87335 15.9109 7.47347 16.4911C8.6937 17.6913 8.76371 19.6717 7.6435 20.9919C6.0832 22.8523 2.08245 23.4324 1.63237 23.4924C1.59236 23.4924 1.54235 23.4924 1.50234 23.4924L1.49234 23.5024ZM5.16303 17.5613C4.84297 17.5613 4.53291 17.6713 4.29287 17.8813C3.60274 18.4614 3.07264 19.9317 2.75258 21.242C4.06282 20.9219 5.5331 20.3918 6.11321 19.7017C6.55329 19.1716 6.54329 18.3814 6.0832 17.9213C5.85316 17.7013 5.5431 17.5713 5.20304 17.5613C5.19304 17.5613 5.17303 17.5613 5.16303 17.5613ZM11.7243 21.8821C11.4942 21.8821 11.2642 21.8021 11.0841 21.652C10.8541 21.462 10.7241 21.1819 10.7241 20.8819V15.9109L8.08358 13.2705H3.11264C2.81259 13.2705 2.53254 13.1404 2.3425 12.9104C2.15246 12.6803 2.07245 12.3803 2.12246 12.0902C2.19247 11.7102 2.84259 8.36953 4.70294 7.12929C6.33325 6.04909 8.96375 6.49918 10.244 6.80923C11.5442 4.96889 13.2546 3.4286 15.2349 2.33839C17.4553 1.11816 19.9858 0.518051 22.4963 0.498047C23.0464 0.498047 23.4865 0.948132 23.4865 1.49824C23.4865 5.0389 22.3763 9.97983 17.1753 13.7605C17.4853 15.0408 17.9354 17.6613 16.8552 19.2816C15.615 21.1419 12.2744 21.7921 11.8943 21.8621C11.8343 21.8721 11.7743 21.8821 11.7143 21.8821H11.7243ZM12.7245 16.181V19.6016C13.7146 19.2916 14.7948 18.7915 15.2049 18.1814C15.675 17.4812 15.605 16.091 15.385 14.9008C14.5248 15.3808 13.6346 15.8109 12.7245 16.181ZM9.66388 12.0302L11.9643 14.3307C13.1845 13.8306 14.3648 13.2204 15.485 12.5103C19.9358 9.51974 21.2361 5.60901 21.4561 2.53843C19.6157 2.67846 17.8254 3.20856 16.2051 4.09872C14.2847 5.14892 12.6544 6.68921 11.4942 8.54956C10.7841 9.65977 10.174 10.82 9.66388 12.0302ZM4.39289 11.2701H7.81353C8.1936 10.3599 8.63368 9.46974 9.11377 8.60957C7.92355 8.38953 6.51329 8.31952 5.81315 8.78961C5.19304 9.19968 4.70294 10.3099 4.39289 11.2701Z\" fill=\"#673DE6\"\/>\n                <\/svg>\n                <p class=\"protip__title\">\n                    Learn Other Expert WordPress Techniques                <\/p>\n            <\/div>\n            <p class=\"protip__content\"><a href=\"\/ca\/tutorials\/wordpress-pagination\/\">WordPress Pagination Guide<\/a><br>\n<a href=\"\/ca\/tutorials\/how-to-setup-and-manage-a-wordpress-cron-job\/\">How to Setup and Manage a WordPress Cron Job<\/a><br>\n<a href=\"\/ca\/tutorials\/best-wordpress-frameworks\/\">12 Best WordPress Frameworks to Design Themes<\/a><br>\n<a href=\"\/ca\/tutorials\/remove-query-strings-static-resources\/\">How to Remove Query Strings From Static Resources<\/a><br>\n<a href=\"\/ca\/tutorials\/what-are-wordpress-hooks\/\">What Are WordPress Hooks? <\/a><br>\n<a href=\"\/ca\/tutorials\/activate-wordpress-multisite\/\">WordPress Multisite: What It Is, How to Activate and Manage It<\/a><\/p>\n                    <\/div>\n        \n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In 2013, WordPress introduced Heartbeat API &ndash; a feature that allows your browser to communicate automatically with the server. However, there are a couple of drawbacks to this feature. If you use a shared hosting plan, you need to take a closer look at the CPU usage of your server, because some hosting companies might [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ca\/tutorials\/wordpress-heartbeat\/\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":100,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"WordPress Heartbeat API: What it is and How to Manage it","rank_math_description":"WordPress Heartbeat API can affect the CPU usage on the server. Learn how to limit or stop WordPress Heartbeat.","rank_math_focus_keyword":"wordpress heartbeat","footnotes":""},"categories":[22698,22692],"tags":[],"class_list":["post-17519","post","type-post","status-publish","format-standard","hentry","category-advanced","category-wordpress"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/wordpress-heartbeat","default":0},{"locale":"en-GB","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/wordpress-heartbeat","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/wordpress-heartbeat","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/wordpress-heartbeat","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/wordpress-heartbeat","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/wordpress-heartbeat","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/wordpress-heartbeat","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/wordpress-heartbeat","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/17519","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/users\/100"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/comments?post=17519"}],"version-history":[{"count":23,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/17519\/revisions"}],"predecessor-version":[{"id":138907,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/17519\/revisions\/138907"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/media?parent=17519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/categories?post=17519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/tags?post=17519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}