#Javascript code runs several times
2 messages · Page 1 of 1 (latest)
It looks like you are using View Transitions, you can read more about script behavior while using View Transitions here: https://docs.astro.build/en/guides/view-transitions/#script-behavior-with-view-transitions
I recommend transforming this code into a Web Component: https://docs.astro.build/en/guides/client-side-scripts/#web-components-with-custom-elements which makes it easier create interactivity while using View Transitions