Turning off Heartbeat in WordPress made my day!

Heartbeat API is a thing built into WordPress that sends a POST request every 15 seconds. It allows for interesting functionalities like revision tracking, but can also dramatically slow things down and even block editors from editing content (if your …


This content originally appeared on Hidde's blog and was authored by Hidde de Vries

Heartbeat API is a thing built into WordPress that sends a POST request every 15 seconds. It allows for interesting functionalities like revision tracking, but can also dramatically slow things down and even block editors from editing content (if your connection is quite slow).

The “Edit” pages in WordPress use the Heartbeat API to detect connection loss. If they detect you’ve lost your connection, your ‘Update’/‘Publish’ button will get disabled until your connection is back.

Why?

“Connection lost” message on slow connections

When I was working on a WordPress site this week, I accessed the internet through my 3G MiFi, and added a VPN for security (the less glamorous side of working remotely). It resulted in seeing the ‘Connection lost’ message all the time. It would usually appear before I could make any changes, and never disappear. In which case it stopped me from editing content.

Screenshot of error message: connection lost, saving has been disabled until you're reconnected, we're backing up this post just in case.! The error message

High CPU usage

Others comment that Heartbeat leads to high CPU usage: imagine having multiple instances of WordPress edit pages open in a browser, each sending its own POST requests every 15 seconds.

Turning Heartbeat off

Only when I just turned the whole thing off, I was able to make changes to my page. Turning Heartbeat off can be done by simply deregistering the script:

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

(via Aditya Nath Jha


This content originally appeared on Hidde's blog and was authored by Hidde de Vries


Print Share Comment Cite Upload Translate Updates
APA

Hidde de Vries | Sciencx (2016-02-08T00:00:00+00:00) Turning off Heartbeat in WordPress made my day!. Retrieved from https://www.scien.cx/2016/02/08/turning-off-heartbeat-in-wordpress-made-my-day/

MLA
" » Turning off Heartbeat in WordPress made my day!." Hidde de Vries | Sciencx - Monday February 8, 2016, https://www.scien.cx/2016/02/08/turning-off-heartbeat-in-wordpress-made-my-day/
HARVARD
Hidde de Vries | Sciencx Monday February 8, 2016 » Turning off Heartbeat in WordPress made my day!., viewed ,<https://www.scien.cx/2016/02/08/turning-off-heartbeat-in-wordpress-made-my-day/>
VANCOUVER
Hidde de Vries | Sciencx - » Turning off Heartbeat in WordPress made my day!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2016/02/08/turning-off-heartbeat-in-wordpress-made-my-day/
CHICAGO
" » Turning off Heartbeat in WordPress made my day!." Hidde de Vries | Sciencx - Accessed . https://www.scien.cx/2016/02/08/turning-off-heartbeat-in-wordpress-made-my-day/
IEEE
" » Turning off Heartbeat in WordPress made my day!." Hidde de Vries | Sciencx [Online]. Available: https://www.scien.cx/2016/02/08/turning-off-heartbeat-in-wordpress-made-my-day/. [Accessed: ]
rf:citation
» Turning off Heartbeat in WordPress made my day! | Hidde de Vries | Sciencx | https://www.scien.cx/2016/02/08/turning-off-heartbeat-in-wordpress-made-my-day/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.