I was not sure if this is due to me looking at the site on a local server through npm or if it would persist when I built it out, but I have 2 components, 1 has javascript imported in its script tag and the other does not. In my main layout including only one of these components with a ternary operator. But the javascript is always ran even if its component isn't included through the ternary operator.
Here is a minimum reproducible example: https://stackblitz.com/edit/astro-js-without-component?file=src/layouts/MainLayout.astro
#JS included without its component.
4 messages · Page 1 of 1 (latest)
Scripts and styles of an Astro component are included on the page as soon as the component is imported, regardless of it being rendered or not
That's kinda not a bug, just a limitation
oh ok, I understand, thank! I can work around it but wasn't sure if I was doing something wrong!
@surreal dove do you know if there is any intent to change this in the future? I can’t believe that this was intended when it was coded