Title: stop heartbeat code
Last modified: May 3, 2017

---

# stop heartbeat code

 *  Resolved [jkin](https://wordpress.org/support/users/jkin/)
 * (@jkin)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/stop-heartbeat-code/)
 * I am excited to learn your wonderful snippet.
    Thanks a lot.
 * Yet, I need help to add following code:
 *     ```
       add_action( 'init', 'stop_heartbeat', 1 );
       function stop_heartbeat() {
       wp_deregister_script('heartbeat');
       ```
   
 * ————-
    The result comes out like this:
 * The code snippet you are trying to save produced a fatal error on line 5:
 * syntax error, unexpected end of file.
    Please advise how to fix this.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/stop-heartbeat-code/#post-9092150)
 * You’re missing a closing `}`. So your snippet should look like this in order 
   to work:
 *     ```
       add_action( 'init', 'jkin_stop_heartbeat', 1 );
       function jkin_stop_heartbeat() {
       	wp_deregister_script('heartbeat');
       }
       ```
   
 * I’ve also renamed the `stop_heartbeat` function to something a little more unique,
   so that there are no name collision errors. However, it’s even better to use 
   something like this instead:
 *     ```
       add_action( 'init', function () {
       	wp_deregister_script('heartbeat');
       }, 1 );
       ```
   
 *  Thread Starter [jkin](https://wordpress.org/support/users/jkin/)
 * (@jkin)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/stop-heartbeat-code/#post-9092732)
 * WOW!!!
 * Thanks sooo much..
 * It works!!
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/stop-heartbeat-code/#post-9092754)
 * No problem, glad to hear it’s working 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘stop heartbeat code’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * Last activity: [8 years, 11 months ago](https://wordpress.org/support/topic/stop-heartbeat-code/#post-9092754)
 * Status: resolved