The WPFolks app is out on iPhone and Android. Free, no ads. Download on the App Store Get it on Google Play
Skip to main content
Login Join
Snippet · PHP

Disable WordPress Heartbeat API on the Frontend

Shared by Amit Dholiya · May 25, 2026

37 views
1 upvote
Back to Snippets

The Heartbeat API sends periodic AJAX requests that can increase server load. Disabling it on the frontend can improve performance on busy sites.

Steps

  1. Open your WordPress theme functions.php file.
  2. Add the code below at the end of the file.
  3. Save the file.
  4. Clear any caches and test your website.

Done — the Heartbeat API will be disabled on the frontend while remaining available in the admin area.

Note: Some plugins rely on the Heartbeat API for frontend functionality. Test your site after enabling this snippet.

function disable_heartbeat_frontend() {
    if (!is_admin()) {
        wp_deregister_script('heartbeat');
    }
}
add_action('init', 'disable_heartbeat_frontend', 1);
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments

Proudly supported by