Turning off Heartbeat in WordPress made my day!
source link: https://hiddedevries.nl/en/blog/2016-02-08-turning-off-heartbeat-in-wordpress-made-my-day
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Turning off Heartbeat in WordPress made my day!
08 February 2016 ・ category: code
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.
“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.
! The error messageHigh 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
Hidde de Vries (@hdv) is a freelance front-end and accessibility specialist in Rotterdam (NL), conference speaker and workshop teacher. Currently, he works for the W3C in the WAI team (views are his own). Previously he was at Mozilla, the Dutch government and various other organisations and businesses.
Leave a comment
Website
Occupation
Posted a response to this?
This website uses Webmentions. You can manually notify me if you have posted a response, by entering the URL below.
© 2007–2020 Hidde de Vries
NederlandsRecommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK