-
Describe your problem 🧐I'm integrating Astro with swup.js in my project, where each component contains script tags. The issue arises during page transitions; the JavaScript within these components does not execute. To address this, I implemented swup.js's Head Plugin, anticipating it would reload necessary JavaScript, as in Astro, JavaScript is typically loaded from the head. Despite this, the expected functionality isn't achieved. I've created a demo on StackBlitz to illustrate the problem. What is your question? 🙋♀️How can I ensure that JavaScript within each component executes correctly during page transitions in an Astro project integrated with swup.js, especially when using the Head Plugin? Despite implementing this plugin, which I thought would reload the necessary JavaScript from the head section during page transitions, the scripts in the components are not executing. Is there a specific configuration or approach I should use to enable seamless JavaScript execution across page transitions in this setup? Thanks in advance for your help 🙏🏼 Really appreciated... URL to minimal reproduction 🔗https://stackblitz.com/edit/withastro-astro-3jsbn4?file=src%2Fpages%2Findex.astro Checked all these? 📚
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 12 replies
-
To insert new scripts and run them as well, you can combine Head Plugin and Scripts Plugin. That's how the official Astro integration does it, and it's working great. Quoting the docs on Common Issues:
|
Beta Was this translation helpful? Give feedback.
To insert new scripts and run them as well, you can combine Head Plugin and Scripts Plugin. That's how the official Astro integration does it, and it's working great. Quoting the docs on Common Issues: