Throttle or Disable the WordPress Heartbeat API Without a Plugin
Reduce WordPress Heartbeat requests by changing the interval or disabling the frontend heartbeat script while keeping the editor working.
The WordPress Heartbeat API sends periodic AJAX requests for features such as post locking, autosaves, and login-session checks. On a busy dashboard or a page that does not use Heartbeat, frequent requests can add unnecessary PHP work.
Throttle it first. Disable it only where you have confirmed that no feature needs it.
Increase the interval
This changes the interval to 60 seconds instead of the default short interval.
add_filter( 'heartbeat_settings', function( $settings ) { $settings['interval'] = 60; return $settings;} );The interval is measured in seconds. A longer interval reduces request frequency but also makes autosave and lock updates less immediate.
Disable Heartbeat on the frontend only
Keep Heartbeat available in the WordPress admin and remove it from public pages:
add_action( 'wp_enqueue_scripts', function() { if ( ! is_admin() ) { wp_dequeue_script( 'heartbeat' ); wp_deregister_script( 'heartbeat' ); }}, 100 );The late priority allows themes and plugins to enqueue their scripts first. Do not apply this globally to the dashboard unless you are willing to lose editor autosaves, post locking, and other Heartbeat-powered features.
Test after changing it
Open the browser Network panel while editing a post and while viewing a normal public page. Confirm that autosaves still work in the editor and that no plugin depends on a frontend Heartbeat event. The WordPress Heartbeat API guide explains the request lifecycle and JavaScript events.
For a broader WooCommerce frontend optimization, see how to disable cart fragments on non-commerce pages.