#Static page, but JS is still shipped
3 messages · Page 1 of 1 (latest)
Hi @rare osprey. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Astro by default processes and bundles all <script> tags in your components, even if they are not used in the final output. This is part of Astro's build process which works on the module graph. Once a component is included in the template, its <script> tags are processed, optimized, and bundled, whether it appears in the final output or not source (https://docs.astro.build/en/guides/troubleshooting/#an-unexpected-script-or-style-is-included).
However, you can prevent Astro from processing a script by adding the is:inline directive to your script tag. This will render the script into the HTML exactly as written. Local imports are not resolved and will not work. If the script is in a component, it repeats each time the component is used source (https://docs.astro.build/en/guides/client-side-scripts/#opting-out-of-processing).
For HTML components, any <script> tags are left unbundled, treated as if they had is:inline source (https://docs.astro.build/en/basics/astro-components/#html-components).
Here's an example of how to use the is:inline directive:
<script is:inline>
// Your script here
</script>