WordPress GuideDevelopment → WordPress Heartbeat

WordPress Heartbeat: What it is and how to use it

Two men work on laptops at a desk

If you’ve ever been surprised by how WordPress autosaves your drafts or locks a post when someone else is editing, you’re already seeing the Heartbeat API in action. But while it brings helpful features, it can also drain server resources if left unmanaged.

Let’s look at what the WordPress Heartbeat API actually does, where it runs, and how to control it for better performance.

Get fast, reliable hosting for WordPress

Power your site with the industry’s fastest, most optimized WordPress hosting

What is the WordPress Heartbeat API?

The WordPress Heartbeat API is a built-in feature, introduced in WordPress 3.6, that enables real-time communication between your browser and the server using Ajax calls. These short, frequent messages let your site perform background tasks like autosaving, post locking, and syncing data with plugins.

It gets its name from how it works—sending out a “pulse” every few seconds to check in with the server.

What does the Heartbeat API do?

The Heartbeat API powers several key features inside the WordPress admin area:

This makes it a quiet but essential part of how WordPress works behind the scenes.

Where and how often does WordPress Heartbeat run?

The API is active mainly in the WordPress admin area, and the frequency depends on where it’s running:

Each of these pulses hits admin-ajax.php, which increases the load on your server. On low-resource hosting plans, this can cause high CPU usage or even timeout errors if multiple users are active.

Pros and cons of the Heartbeat API

It’s always a balance.

Pros:

Cons:

How to control or disable the WordPress Heartbeat API

If you’re seeing performance issues or just want more control, you can manage the Heartbeat API with or without code.

Use a plugin (recommended)

The best way to manage the Heartbeat API without touching code is with WPCode. It’s a powerful plugin that lets you add custom PHP snippets safely and easily—no need to edit your theme files.

With WPCode, you can:

Control it manually via code

If you’re comfortable editing your theme’s functions.php or using a code snippet plugin, you can manage Heartbeat manually.

Change Heartbeat frequency:

add_filter( ‘heartbeat_settings’, ‘custom_heartbeat_frequency’ );
function custom_heartbeat_frequency( $settings ) {
    $settings[‘interval’] = 60; // seconds
    return $settings;
}

Disable Heartbeat in the dashboard:

add_action( ‘init’, ‘stop_heartbeat’, 1 );
function stop_heartbeat() {
    if (is_admin()) {
        wp_deregister_script(‘heartbeat’);
    }
}

Use these carefully—disabling Heartbeat entirely can break autosave and post locking.

When should you disable or modify the Heartbeat API?

Some common use cases for tweaking or limiting Heartbeat:

Always test changes before deploying them on a live site.

Tips for optimizing Heartbeat without turning it off

If you want to keep the benefits without the resource hit:

Advanced usage: developers and Heartbeat custom events

If you’re a developer or running custom functionality, the Heartbeat API supports custom data events:

This opens up use cases like live analytics, real-time chat, or collaborative editing. Just be cautious with frequency and payload size to avoid performance issues.

Ready to get started?

Get the fastest, most secure WordPress.org hosting on the market.

Additional resources

What is managed WordPress hosting? →

Get details and decide if managed WordPress hosting is right for you.

How to install WordPress with Nginx →

Learn how to install and configure WordPress with NGINX for improved performance and flexibility.












A complete guide to WordPress shortcodes →

Shortcodes make life easier. Learn how to get started!

Trust us to help you choose the ideal hosting solution

Loading form…