Retrigger DOMContentLoaded or rocket-DOMContentLoaded after using facets

<?php
/** Trigger DOMContentLoaded after using facets
 **/

add_action('facetwp_scripts', function () {
  ?>
  <script>
    document.addEventListener('facetwp-loaded', function() {
      if (FWP.loaded) {
        window.document.dispatchEvent(new Event("DOMContentLoaded", {
          bubbles: true,
          cancelable: true
        }));
      }
    });
  </script>
  <?php
}, 100);


/**
 ** Change 'DOMContentLoaded' to 'rocket-DOMContentLoaded' to  if you are using WP Rocket lazy load
 **/
add_action('facetwp_scripts', function () {
  ?>
  <script>
    document.addEventListener('facetwp-loaded', function() {
      if (FWP.loaded) {
        window.document.dispatchEvent(new Event("rocket-DOMContentLoaded", {
          bubbles: true,
          cancelable: true
        }));
      }
    });
  </script>
  <?php
}, 100);