Delay Filter loading - My script needs to load first =(

I’ve written a code that removes an element from the DOM, if certain conditions are met.

Problem is…

It needs to load BEFORE Finsweet’s Filter, because, the “Count Items” attribute counts the items on my list before my script removes them.

So, when my script runs, it removes the element, but finsweet Count Items is still counting the total from before

How can I delay Finsweet’s script to load?

PS: My script needs to load after all elemens are loaded.

  1. All elements are loaded
  2. My script runs
  3. Finsweet’s script runs

Hey @dan1! You can prevent CMS Filter from running with this script

<!-- [Attributes by Finsweet] CMS Filter -->

You can then initialize CMS Filter with these lines after your script is done

window.fsAttributes = window.fsAttributes || [];

And to check everything is working you can add this callback

    (filterInstances) => {
      console.log('cmsfilter Successfully loaded!');

      const [filterInstance] = filterInstances;

      filterInstance.listInstance.on('renderitems', (renderedItems) => {

Will try! Thanks, Luis!

1 Like