If you open the above page in a browser, you’ll see an alert when each local script is being executed. The expected sequence is “script1”, “script2”, “script”, “script2”, “script”, “main”.

Here the first script hierarchy is alerted because it’s directly loaded into the page, the second “script2” on the other hand is alerted because it’s required by script, which is required by main, which is directly loaded into the page.

As you see, script has been loaded twice because it’s required in redo mode by main, and its children are exporting times according to their respective modes: for script1 the mode is link (default), and for script2 it is exec. So, both script1‘s entries in the goon repository export the same time, while script2‘s entries export different times.

Priorities

An interesting observation about the above picture: in the first script entry, exported.diff is negative. This is not the result of a bug, because script requires script1 and script2 “in parallel”, so script1 will be executed before script2 mostly (because it is declared before), but not always.

In Goon 1.0, to guarantee that script1 is executed always before script2, the setup must be different: main( script( script2( script1() ) ) ) instead of main( script( script1(), script2() ) ), thus making script2 require script1, even if script2 does not need script1 to work…

With priorities implemented, it will be possible to specify something like the above expression, right where it belongs, i.e. inside script. Goon will support priorities in the future.