#Two basic questions re javascript in Astro
9 messages · Page 1 of 1 (latest)
I've never done (2) but i'm not sure Astro interpreter would process the scripts differently between strict / non strict modes. (would love to know the answer to this as well!)
(1) i normally extract pure functions to separate JS files outside .astro. not only is it reusable between multiple components, but also easier to test and possibly reuse in non-Astro apps.
Thanks! Do you extract them to /src/scripts or something?
yeah, i usually have src/utils/ but of course it can be named anything
Right. Nice, I’m going to sort through and see what I can extract 🙂
if i only use it once, i normally dont bother 😁 . once i find myself repeating/copy-pasting 2-3 times, i extract it.
Yeah, good point. Unless perhaps it’s such a lovely function that it would look better in a room of its own
Still hoping to get some feedback on this part of my question:
- Is it meaningful or redundant to add
use strictto scripts in Astro?