Best practices to write reusable JS functions

I need to create a reusable function that needs to be accessible from various points within an application. I'm contemplating whether to craft a new JavaScript query specifically for this function, employ a transformer, or simply place it within the Preloaded JavaScript section under the app settings. Could you please provide guidance on the best practices for this scenario?
I checked this post but couldn't find App Actions anywhere in Retool. (I am on the Self Hosted version of Retool)