Discourse is a single-page application. So, the scripts you add in the <head> tag only fire once on the initial page load unless you use the right hooks. You probably need to tweak your code to add an event listener instead.
Can you share your code?