Blocking JS from being executed more than once
I adjusted your code to match the one from the docs.

MYMODULE/js/myscripts.js:

(function ($, Drupal) {
  Drupal.behaviors.myModuleBehavior = {
    attach: function (context, settings) {

      $('.block-facets-ajax', context).once('myModuleBehavior').each(function () {
        // Apply the myModuleBehavior effect to the elements only once.
        $(this).wrapAll('&lt;div class="facets-wrap"&gt;&lt;/div&gt;');
      });

    }
  };
})(jQuery, Drupal);




To get that working properly you also need to require core/jquery.once for this script.

MYMODULE.libraries.yml:

myscripts:
  version: VERSION
  js:
    js/myscripts.js: {}
  dependencies:
    - core/jquery
    - core/jquery.once