Perspective Script Locations

I am looking for advice on the best organization of scripts in Perspective.
I know you can have scripts on component events, transforms, root container methods, in a scripting module, etc.
Are there any differences in performance between running scripts in a session vs. calling a module?

And feel free to compare/contrast with an example:

  • recipe entry using an editable table
  • button scripts (currently) on the root container to execute: Save, Delete, Load, etc.

Where the script is written does not have any (appreciable) performance implication. Where it is called will.

For ease of maintenance, I would strongly recommend writing as much as possible into project scripts.

ok thanks for the insight. another question:
if my table has scripts for CellEdit and cell color changes, would you still recommend those be in a project script?
Or would you expect those to execute better on the component itself?

Well, unless you are nesting function and/or class definitions. You really want to put those in script modules. Possibly only excepting clever use of closures for short function definitions.

If it’s truly something that only changes a single component, and you can’t ever predict a future where the script could be re-used on another component, then it can reside on the local component.

What I meant in the first post is that there’s very, very little overhead between a script transform running some code directly, or a script transform calling a function defined in a project script. In more exotic scenarios there can be recompilation overhead, to Phil’s point, but if the difference is just taking logic out of one place and putting it directly in a def in a project library, you should absolutely not worry about performance based on the calling convention.