🎉 Use coupon MYXERO to enjoy 20% recurring discount on any plan. View Pricing

How to Optimize WordPress Performance by Disabling the Heartbeat API Using Simple Code Snippets

XeroWP May 17, 2026 5 min read
How to Optimize WordPress Performance by Disabling the Heartbeat API Using Simple Code Snippets

The Silent Performance Killer: Understanding the WordPress Heartbeat API

If you have ever noticed your WordPress admin area feeling sluggish or your hosting provider complaining about high CPU usage even when traffic is low, you might be a victim of a 'racing' Heartbeat. Introduced in WordPress 3.6, the Heartbeat API is a powerful feature that allows WordPress to communicate between the web browser and the server in real-time. While it enables essential features like autosaving posts and session management, it can also become a significant performance bottleneck if left unmanaged.

At XeroWP, we believe in lean, high-performance WordPress installations. In this guide, we will dive deep into what the Heartbeat API does, why it might be slowing you down, and how you can take control of it using simple code snippets without relying on heavy plugins.

What Does the Heartbeat API Actually Do?

The Heartbeat API uses a communication protocol called 'polling.' Essentially, your browser sends an AJAX request to the server via the admin-ajax.php file at regular intervals. The server then responds with data, allowing the WordPress dashboard to update dynamically without a full page refresh.

Key functions powered by the Heartbeat API include:

  1. Autosave and Revisions: Periodically saving your work while you are writing a post.
  2. Post Locking: Warning you if another user is currently editing the same post to prevent overwriting changes.
  3. Session Management: Monitoring when a user's session expires and prompting them to log back in.
  4. Plugin Notifications: Allowing developers to show real-time alerts or data updates in the dashboard.

By default, the API 'ticks' every 15 seconds while you are editing a post and every 60 seconds when you are just sitting on the dashboard. While this sounds harmless, every single 'tick' is a full PHP execution. Multiply that by several open tabs and multiple users, and your server's CPU can quickly hit 100% capacity.

Why You Should Consider Disabling or Limiting It

For many site owners, the default settings are overkill. If you are the only person managing your site, you might not need post-locking. If you save your drafts manually or use an external editor, the aggressive 15-second autosave might be unnecessary.

The primary issue is that admin-ajax.php cannot be easily cached by standard page caching layers. This means every request hits your server's PHP-FPM process and database directly. On managed hosting like XeroWP, our infrastructure is built to handle spikes, but on shared hosting, this is often the #1 cause of 'Account Suspended' notices for resource overages.

Method 1: Completely Disabling the Heartbeat API

If you want the maximum performance boost and don't care about autosaves or real-time notifications, you can disable the API entirely. This is the 'nuclear option.' It stops all requests to admin-ajax.php related to the heartbeat.

Add the following code to your theme's functions.php file or a functional plugin:

add_action( 'init', 'xerowp_stop_heartbeat', 1 );
function xerowp_stop_heartbeat() {
    wp_deregister_script('heartbeat');
}

Warning: Disabling it completely will break the 'Post Lock' feature and automatic session expiration warnings. If you have a multi-author blog, use this with caution.

Method 2: Disabling Heartbeat Everywhere Except the Post Editor

This is the most popular approach for performance-conscious developers. It allows you to keep the vital 'Autosave' and 'Post Lock' features while writing content, but stops the server from being hammered while you are just browsing the Dashboard or viewing the front end of your site.

add_action( 'init', 'xerowp_limit_heartbeat', 1 );
function xerowp_limit_heartbeat() {
    global $pagenow;
    
    // Keep heartbeat only on post edit pages
    if ( $pagenow !== 'post.php' && $pagenow !== 'post-new.php' ) {
        wp_deregister_script('heartbeat');
    }
}

This snippet checks the current page. If you aren't in the editor (post.php or post-new.php), it deregisters the script, saving your server from thousands of unnecessary requests every day.

Method 3: Slowing Down the Heartbeat Frequency

If you don't want to disable the API but simply want it to be less aggressive, you can modify the frequency of the 'ticks.' By default, the editor pulses every 15 seconds. We can change this to 60 seconds (the maximum allowed by the API) to reduce server load by 75%.

add_filter( 'heartbeat_settings', 'xerowp_slow_down_heartbeat' );
function xerowp_slow_down_heartbeat( $settings ) {
    $settings['interval'] = 60; // Set interval to 60 seconds
    return $settings;
}

This is the 'Goldilocks' solution: you keep all the features, but you significantly lower the resource footprint.

How to Verify Your Optimization is Working

After implementing any of the snippets above, you should verify that the requests have actually stopped or slowed down. You don't need fancy tools; your browser's built-in developer tools are enough.

  1. Open your WordPress Dashboard.
  2. Right-click and select Inspect (or press F12).
  3. Navigate to the Network tab.
  4. In the filter box, type admin-ajax.php.
  5. Watch the list. If you disabled the heartbeat, no new requests should appear. If you slowed it down, you should see a new entry only once every minute.

Performance Beyond the Heartbeat

While managing the Heartbeat API is a fantastic step toward a faster site, it is just one piece of the puzzle. Performance optimization is a holistic process that involves clean code, optimized images, and, most importantly, a hosting environment designed for speed.

At XeroWP, we optimize the server environment so you don't have to spend all day chasing micro-optimizations. Our platform includes built-in object caching and server-side optimizations that make even the most 'talkative' WordPress sites run smoothly. However, combining great hosting with smart code practices like these heartbeat tweaks is the secret recipe for a truly lightning-fast website.

Final Takeaway

Don't let your WordPress site's heartbeat skip a beat—or beat too fast! By using the snippets provided, you can dramatically reduce the strain on your server and provide a snappier experience for your editors and visitors alike. Start by limiting the API to the post editor; it’s the best balance between functionality and performance. Ready to host your optimized site on a platform that handles the heavy lifting for you? Check out XeroWP's managed hosting plans today.