Great question!
IMO, that is the best approach:
Run all AppleScripts, JXA scripts, and JavaScripts from a file this referenced in the KM Execute Script Action, for these reasons:
- Compiled scripts (.scpt) will run faster because they do not have to be first compiled by KM.
- Keeping all of these scripts in a designated KM Scripts folder provides for much better script management and testing
- It is much easier to test/debug a script, open in Script Debugger 7, but run from a KM Macro.
- Allows you to quickly find scripts using macOS tools like Spotlight, especially when you use file tags.
- Allows you to take advantage of other systems like DropBox, GitHub, etc
The only drawback I know of is that when you want to share a KM Macro, you either have to also provide the script file, or copy the script into the KM Execute Script Action.
AFAIK, there is no official KM documentation on using script text vs a script file, but hopefully @peternlewis and @ccstone will jump in here to clarify.
I have a Script Library in which I keep most of my reusable script handlers. So for KM Macros for my own use, I make use of the use <Script Library> command to access these handlers from my scripts. I have a KM Macro which aids in the search, selection, and insertion of a call to a handler in this Library. It can also copy the handler directly into the target script, if I need to share that script without sharing my Script Library.
Questions?