David Kimura PRO said almost 7 years ago on Page Specific Javascript in Ruby on Rails :

I believe that it does. Not everything needs to be a Stimulus component. Sometimes it just makes sense to have some JS sprinkles where needed. I have personally never been a huge fan of page specific javascript as it seems like there is some disconnect in the architectural planning of the application. I typically tend to write JS functions so that they can be called on later in Server Rendered Javascript responses, when launching a bootstrap modal or wherever else appropriate.