JXA/KM Strategy Brainstorming - Please jump in with your thoughts!

I'm working on something that is quite complex, and it involves a large JXA script - around 3,600 lines. The script is a "Core" type of script, meaning it can do a lot of things, depending on the parameters.

So as my KM Macro instance runs through various tasks, it calls the JXA script multiple times.

The problem is, it takes KM around a half second to load up the JXA script and get it running, each time it is run.

So here's what I'm toying with:

Instead of using a KM Macro as the driver, I'm thinking it might actually be better to have the JXA script be the driver, and execute KM macros as needed. The overhead of calling a KM Macro from a JXA script is around 50 milliseconds, so that seems trivial to me.

I'm just toying with the idea right now. But I wonder what other people think.

I hope I've explained it well enough. Chime in, please!

So I'm way over my skis here, but sometimes dumb questions can lead smart people like you to brilliant solutions. :slight_smile:

Would you have a KM macro launch the core JavaScript process (once, so the overhead cost occurs only one time)?

Would that core process continue running until it receives an exit command.

When the core process is running, would it be responsible for event detection, or would that be done by KM macros? If the latter, would commands and argument values be sent from the macro(s) to the core process?

Apparently not over your skill level after all. A well-worded response.

I would launch the core process, and it would be responsible for everything else. It would run a KM macro to, say, get the XML for the currently-selected action. Actually, that would probably happen before I launch the JXA macro, but just go with it.

Once the macro returned the XML, the JXA code would decide what to do next depending on what kind of action was selected. In some cases the JXA can do everything itself, but when actions like Comments are involved, I might need to execute another KM Macro from the JXA, and wait for the response.

The more I think about it, the more I think this will be best. I'll do some experimenting and see what kind of gotchas I run into.

And thanks for making my brain think about more clearly!

1 Like

FYI, running it all from JXA is turning out to be faster - WAY WAY faster.

1 Like