Disable WordPress Heartbeat API Without Plugin Full Guide

Why need to disable WordPress heartbeat API?

The WordPress Heartbeat API runs in the background, and it continuously transmits the AJAX requests between your browser and the server.

It empowers WordPress users with highly attractive and useful features like post auto-save and session management. But the issue is that users have to bear the cheap or overloaded hosting. It also increases the CPU usage and pulls down its speed and overall performance.

This post will guide you here how to disable WordPress Heartbeat API without using any plugin, directly via functions.php.

You will get here all these options.

  • Completely disable Heartbeat everywhere
  • Only limit (slow down) Heartbeat
  • Disable Heartbeat on the frontend only
  • Disable Heartbeat on admin screens except the post editor
Disable WordPress Heartbeat API

You may also need this: Minify CSS and JS

What Is the WordPress Heartbeat API?

The WordPress Heartbeat API is a built-in mechanism. It sends background requests (using AJAX) between the browser and server at regular intervals.

Here are some examples of its functions.

  • Auto-saves posts while you’re writing
  • Shows “Another user is editing this post”
  • Keeps your login session alive
  • Used by some plugins for real-time features

The Heartbeat API is designed to send a request every 15–60 seconds, depends on the page.

If the hosting is weak, these frequent background calls create unnecessary load on the CPU and its memory. It happens especially if multiple users are in the admin at the same time.

When Should You Disable WordPress Heartbeat API?

You may want to control the Heartbeat API if:

  • Your hosting provider reports high CPU usage
  • You notice slow WordPress admin performance
  • You’re the only person editing posts (no need for post lock)
  • You don’t need real-time features or live notifications

The best practice to follow is –
If you want auto-save and safe editing, don’t blindly kill it completely. Instead, slow it down or disable it only where not needed.

How to Safely Edit functions.php to Disable WordPress Heartbeat API

Before adding any code, always:

  1. Use a child theme (so changes are not lost after theme update).
  2. Take a quick backup of your existing functions.php.
  3. If possible, test on a staging site.

Path example:
/wp-content/themes/your-child-theme/functions.php

Now let’s go through the options. You can use any one of these methods depending on what you want.

Option 1: Completely Disable WordPress Heartbeat API (Everywhere)

Use this only if you don’t need auto-save or post locking at all.

// Disable WordPress Heartbeat API everywhere
function wpwp_disable_heartbeat_everywhere() {
    wp_deregister_script( 'heartbeat' );
}
add_action( 'init', 'wpwp_disable_heartbeat_everywhere', 1 );

What this does:

  • Stops Heartbeat API on frontend and backend
  • No more background AJAX heartbeat calls
  • Reduces server load the most
  • But: Auto-save and editing warnings will no longer work

Option 2: Limit (Slow Down) Heartbeat Frequency

This is a safer and recommended approach if you still want auto-save but with less server load.

// Limit WordPress Heartbeat frequency
function wpwp_limit_heartbeat_frequency( $settings ) {
    // Interval in seconds (default is 15–60, depending on screen)
    $settings['interval'] = 60; // 60 seconds
    return $settings;
}
add_filter( 'heartbeat_settings', 'wpwp_limit_heartbeat_frequency' );

You can change 60 to 30 if you want slightly more frequent updates but still lighter than default.

Effect:

  • Heartbeat still works
  • Requests per minute are reduced
  • Better balance between performance and features

Option 3: Disable Heartbeat on Frontend Only

Usually, you don’t need Heartbeat on the frontend at all. It’s mostly useful in the admin area.

// Disable Heartbeat on the frontend only
function wpwp_disable_heartbeat_frontend() {
    if ( ! is_admin() ) {
        wp_deregister_script( 'heartbeat' );
    }
}
add_action( 'wp_enqueue_scripts', 'wpwp_disable_heartbeat_frontend', 1 );

Effect:

  • No Heartbeat calls on public pages (frontend)
  • Admin features like auto-save still work
  • Good for reducing load on busy sites with many visitors

Option 4: Disable Heartbeat Everywhere Except Post Editor

This is a balanced option –
You keep Heartbeat only in the post editor, where auto-save and post locking are genuinely useful.

// Disable Heartbeat everywhere except post editor
function wpwp_control_heartbeat_admin() {
    global $pagenow;

    // Allow Heartbeat only on post editor pages
    if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) {
        return;
    }

    // Disable Heartbeat on all other admin pages
    wp_deregister_script( 'heartbeat' );
}
add_action( 'admin_enqueue_scripts', 'wpwp_control_heartbeat_admin', 1 );

Effect

  • Heartbeat is active only when editing posts
  • Disabled on dashboard, plugin pages, settings pages, etc.
  • Solid performance improvement without losing critical editor features

Which Option Should You Use?

Here’s a quick decision guide.

  • Low-traffic blog, simple use
    Use Option 2 (Limit Heartbeat) or Option 4
  • Heavily loaded shared hosting, you’re careful with drafts –
    Use Option 3 (Disable frontend) + optionally Option 2
  • You really don’t care about auto-save or multi-user editing:
    Use Option 1 (Disable everywhere)

Testing Notes

Tested on: WordPress 6.6+, Astra Pro, PHP 7.4 / 8.0 / 8.2
Verified on: Google PageSpeed, Cloudflare CDN, Mobile & desktop browsers

After adding the code –

  • Clear any caching plugin + Cloudflare cache.
  • Open your site in an incognito window and browse.
  • Check your hosting resource usage after a few hours or a day.

Conclusion

The post guides WordPress site users about the process and options to Disable WordPress Heartbeat API. The code is shared to make your website lightweight and efficient.

Kindly share your suggestions and queries in the comment section. We read all the comments and respond to our readers.

Thank You.

FAQs – Heartbeat API in WordPress

Is it safe to disable the Heartbeat API completely?

Yes, WordPress will still work, but you’ll lose auto-save and post-locking features. If your internet disconnects or browser crashes while editing, you may lose more content than usual. For most users, it’s better to limit or selectively disable instead of killing it everywhere.

Will limiting Heartbeat speed up my site?

On some hosts, yes. Reducing background AJAX calls can lower CPU usage and make the admin feel more responsive, especially if multiple users are logged in. On small sites, the difference may be small but still helpful.

Do plugins depend on Heartbeat?

Some plugins (especially real-time ones, like certain editors, notifications, or activity trackers) may rely on the Heartbeat API. If something behaves strangely after disabling it, switch to Option 2 (limit) or Option 4 (allow in editor) instead of fully disabling.

Can I do this with a plugin instead of code?

Yes, there are dedicated plugins for Heartbeat control, but this article focuses on “without plugin” methods to keep your site light and under your full control.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top