Support client: directives on <script> tags #102
Replies: 2 comments
-
I like this idea! |
Beta Was this translation helpful? Give feedback.
-
Im certain this was asked a while ago, mind you there is xelement that would help take care of this sort of issue, where you can apply your code to |
Beta Was this translation helpful? Give feedback.
-
Sometimes I want to add a teeny-tiny bit of interactivity to my site without having to add all the extra weight that comes with a whole front-end framework. This can easily be done using
<script>
tags inside of.astro
files, but has the downside of not being able to use all of theclient:
directives available when using components from frameworks.What I propose is allowing all of the existing
client:
directives (except maybeclient:only
- not sure how that would work) to be used on<script>
tags inside of.astro
files.The current approach of only supporting the
client:
directives on components for fully-fledged front-end framework feels like it treats vanilla JavaScript as a second-class citizen, which just feels wrong.I also considered supporting the
client:
directives on Astro components instead of just<script>
tags, but decided against it because of the confusion that could create around what does/doesn't run on the server, and it would also make using the directives on scripts at the top level inside of routing.astro
files (the ones insrc/pages/
) impossible.Beta Was this translation helpful? Give feedback.
All reactions