Script is not working on publish

Hello,
I am trying to embed a script inside a cloned module’s, which name is post filter, hubl codes . When in edit mode, I preview the page and I see the script is working but when I publish the page, the script is not working on published page. What can I do to make this work?

@AKılınçtekin did you replace the module on the page with the new cloned module that has the script?

If it’s still the original module before you added the script, it won’t update on the page.

Yes, I replaced the module. I see the changes on the preview actually. But as I said before, I cannot see the changes on the published page.

@AKılınçtekin can you share more about what the script is supposed to do?

page link? script name JS name?

{# Module variables #}

{% if module.select_blog is number %}
{% set select_blog = module.select_blog %}
{% else %}
{% set select_blog = “default” %}
{% endif %}

{% if module.show_all_filters == true %}
{% set max_link_param = “” %}
{% else %}
{% set max_link_param = module.max_links %}
{% endif %}

{# Module content #}

{% post_filter
select_blog=“{{ select_blog }}”,
expand_link_text=“{{ module.expand_link_text }}”,
list_title=“{{ module.list_title }}”,
filter_type=“{{ module.filter_type }}”,
order_by=“{{ module.order_by }}”,
max_links={{ max_link_param }}
%}

<script>
document.addEventListener(‘DOMContentLoaded’, () => {
const links = document.querySelectorAll(‘.filter-link-count’)
links.forEach((link) => {
if(link.textContent <= 15) {
link.parentNode.parentNode.remove()
}
})
})
</script>
Here is my script. There are too many -more than 300- links on the page. So that I wanted to remove some <li> elements. Normally scripts should do its job.

Thanks @AKılınçtekin, without seeing the live page to check the deve console for errors, I can’t tell why the script isn’t working.

Maybe @Anton can offer further feedback on the code directly.

Sorry for my late response, here is the live page: AWS re:Invent 2023 Highlights and Key Takeaways

@AKılınçtekin here’s the error: