Over the last few days, I’ve been writing more JavaScript than usual. The reason? I am using Stimulus a lot more in one of my Rails projects.

Enhancing the functionality of my Rails application with some HTML markup and a JavaScript controller is good, as Stimulus has a small learning curve and integrates well with Rails.

As I add more Stimulus to the application, though, I am learning some of its best practices the hard way. One criticism I have of my own controllers is that they are very page-specific. That’s fine for now, as the application is relatively small. Still, I plan to break these controllers into more generic behaviours that can be re-used more easily across the application in the future.