WordPress Heartbeat: What It Is and How to Optimize It

WordPress Heartbeat is a built-in background API that enables real-time communication between your browser and server without reloading the page.

It works like a periodic “pulse” to keep WordPress updated while you are logged in.


How It Works

  • Uses AJAX requests via admin-ajax.php
  • Runs automatically in:
    • Admin dashboard
    • Post / page editor
    • Frontend (for logged-in users)

Default Intervals

AreaInterval
Post Editor15 seconds
Dashboard60 seconds
Frontend60 seconds

Why It Matters

  • Autosave (prevents data loss)
  • Post locking (avoids conflicts)
  • Session management
  • Plugin real-time updates

Without it, key WordPress features stop working.


Pros and Cons

Pros

  • Prevents content loss
  • Improves collaboration
  • Supports plugins

Cons

  • Frequent admin-ajax.php calls
  • Higher CPU usage on weak hosting

Best Practice

Do not disable Heartbeat completely.

  • Disable on frontend
  • Limit usage in dashboard
  • Keep active in editor

Recommended Settings

Basic Website

  • Frontend: Disabled
  • Dashboard: Disabled
  • Editor: 60s

WooCommerce (Small)

  • Frontend: Disabled
  • Dashboard: 45s
  • Editor: 30s

WooCommerce (Large)

  • Frontend: Disabled
  • Dashboard: 30s
  • Editor: 15–20s

Membership / LMS

  • Frontend: Enabled (limited)
  • Dashboard: 15–20s
  • Editor: 15s

Multi-Author / Editorial

  • Frontend: Disabled
  • Dashboard: 30s
  • Editor: 15s

Safe Optimization Code

Add this to your theme functions.php: (You can also use plugins to optimize WordPress Heartbeat)

add_action( 'init', function () {

    if ( ! is_admin() ) {
        wp_deregister_script( 'heartbeat' );
        return;
    }

    $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;

    if ( $screen && $screen->base !== 'post' ) {
        wp_deregister_script( 'heartbeat' );
    }
});

add_filter( 'heartbeat_settings', function ( $settings ) {
    $settings['interval'] = 60;
    return $settings;
});

Final Takeaway

WordPress Heartbeat is essential for core functionality. Performance issues usually come from high frequency, not the feature itself.

  • Simple sites → limit aggressively
  • WooCommerce → balance performance
  • Membership / editorial → keep active

Proper tuning improves performance without breaking functionality.