PHP snippet · Performance
Disable Heartbeat on the front end
Stops the Heartbeat API polling admin-ajax.php on public pages. Autosave, post locking, and the editor keep working untouched.
About this php snippet
The Heartbeat API polls admin-ajax.php on a timer to power post locking, autosave, and the session expiry warning. All of that matters in wp-admin. On a public page, there is nothing for it to do, yet it still fires an uncached, fully bootstrapped PHP request every 15 to 60 seconds for every tab a visitor leaves open.
On a site with real traffic, that is a steady stream of requests your page cache can never absorb, arriving at the slowest entry point WordPress has.
What it does
- Deregisters the Heartbeat script on front-end requests only
- Leaves wp-admin and both editors completely alone
- Runs early in the enqueue pass, before anything can pick it up as a dependency
Good to know
- Autosave, post locking, and the session expiry warning all keep working where they matter, which is inside the admin
- The script is deregistered rather than dequeued, on purpose. Anything on the front end that genuinely depends on Heartbeat fails loudly here instead of half working, so you find out immediately rather than in a bug report weeks later.
- Worth a quick check first if you run a booking, membership, or live-chat plugin that leans on Heartbeat for front-end updates
- Nothing to configure. Activate it and the polling stops.



