dan1
1
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.
- All elements are loaded
- My script runs
- Finsweet’s script runs
Hey @dan1! You can prevent CMS Filter from running with this script
<!-- [Attributes by Finsweet] CMS Filter -->
<script
defer
fs-attributes-preventload="true"
src="https://cdn.jsdelivr.net/npm/@finsweet/attributes-cmsfilter@1/cmsfilter.js"
></script>
You can then initialize CMS Filter with these lines after your script is done
window.fsAttributes = window.fsAttributes || [];
window.fsAttributes.cmsfilter.init();
And to check everything is working you can add this callback
<script>
window.fsAttributes.push([
'cmsfilter',
(filterInstances) => {
console.log('cmsfilter Successfully loaded!');
const [filterInstance] = filterInstances;
filterInstance.listInstance.on('renderitems', (renderedItems) => {
console.log(renderedItems);
});
},
]);
</script>