I have a number of Applescripts that I have saved as applications, and I have noticed that when I run a script, and I haven’t run one in a while, it will take 10-15 seconds to launch. If I run that same application a second or even a few minutes later, it will take 1 second. Why is this, and is there a way that I can get fast performance consistently?
I think it is because it updates internal datastructures and such in your script while you launch it initially again, which I would guess would be after you have edited it.
I can’t understand that it is anything other than that, not seeing applications having some date expiry on their state, but the reason for it taking so long, is I think because it rebuilds its state.
I am not sure if there is a way to make an applet behave consistently regarding this. but maybe it can help to set a property at the top level of your main script.
property parent : AppleScript
I’d also go for not returning anything when quitting the script, either by a return statement without anything or error number âˆ’128. This to prevent the script runner to save the state upon exit.
Then I would get wanted for saved state from a script object, loaded with values, and saved during execution, by need, as you need those properties. Should you.
This approach will ofcourse make things somewhat slower than the quick runs after the first time, but will hopefully lead to overall consistent behaviour.
The main reason to the slow starte is of course that your applet compiles the first time after you have edited it.
I hope this helps