Is there any way to fire heartbeat API from for website visitors?

I saw that Heartbeat API is fired when someone is logged in the Wordpress. Is there any way to fire it for website visitors?

Topic heartbeat-api plugin-development Wordpress

Category Web


As Mark Kaplun says in the comments, you shouldn't do it. But here's how to enqueue the heartbeat script for all users on the public side... if you really, really want to overload your server.

add_action( 'wp_enqueue_scripts', 'enqueue_heartbeat' );
function enqueue_heartbeat() {
  wp_enqueue_script( 'heartbeat', includes_url( js/heartbeat.js ) );
}

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.