Need help with making a dynamic slider hide slides not set in CMS

I got this to work by removing the Webflow.push wrapper and making sure the DOM is loaded before removing the empty slides

<script>

document.addEventListener("DOMContentLoaded", function(event) { 
  $(".w-condition-invisible").remove();
});

</script>

Thanks Sam, that solved it for me