Title: JS initilization
Last modified: July 6, 2023

---

# JS initilization

 *  Resolved [michaeloestergaard](https://wordpress.org/support/users/michaeloestergaard/)
 * (@michaeloestergaard)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/js-initilization/)
 * I’m trying to find the JS initialization code for the wpulike button is (aka.
   checking if a user has liked a post or not)? See the message below for more information
   about my issue.
 * I hope someone can help.
 * The reason why I need the code, is explained below:
 * Hello,
 * On ajax refresh, FacetWP works by destroying and re-creating any DOM elements
   within the listing container element.
 * The side effect is that this also destroys any JS event listeners, which could
   explain why wpUlike isn’t working after refresh. The solution involves figuring
   out upUlike’s JS initialization code, and adding it into a [facetwp-loaded JS event](https://facetwp.com/help-center/developers/javascript-reference/facetwp-loaded/)(
   so that it re-runs after each ajax refresh).
 * He’s a similar example… but to figure out the actual code needed, you may need
   to reach out to the wpUlike team: [https://gist.facetwp.com/gist/re-trigger-ele-custom-skin-js-post-item-links-on-facetwp-loaded/](https://gist.facetwp.com/gist/re-trigger-ele-custom-skin-js-post-item-links-on-facetwp-loaded/)
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fjs-initilization%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Alimir](https://wordpress.org/support/users/alimir/)
 * (@alimir)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/js-initilization/#post-16875685)
 * Hey [@michaeloestergaard](https://wordpress.org/support/users/michaeloestergaard/)
   
   Please try following sample code and let me know if you had any issues:
 *     ```wp-block-code
       add_action( 'wp_footer', function() { ?>
           <script>
             (function($) {
   
               document.addEventListener('facetwp-loaded', function() {
                 $(".wpulike").WordpressUlike();
               });
   
             })(fUtil);
           </script>
         <?php
       }, 100 );
       ```
   
 *  Thread Starter [michaeloestergaard](https://wordpress.org/support/users/michaeloestergaard/)
 * (@michaeloestergaard)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/js-initilization/#post-16875827)
 * Thank you very much. It couldn’t make it work though.
 * Can it be because I’m using wpUlikePro, and the heart template?
 * Looking forward to hear from you.

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

The topic ‘JS initilization’ is closed to new replies.

 * ![](https://ps.w.org/wp-ulike/assets/icon.svg?rev=2453069)
 * [WP ULike – Like & Dislike Buttons for Engagement and Feedback](https://wordpress.org/plugins/wp-ulike/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-ulike/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-ulike/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-ulike/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-ulike/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-ulike/reviews/)

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * 2 replies
 * 2 participants
 * Last reply from: [michaeloestergaard](https://wordpress.org/support/users/michaeloestergaard/)
 * Last activity: [2 years, 11 months ago](https://wordpress.org/support/topic/js-initilization/#post-16875827)
 * Status: resolved