exec mode

To show the effect of the exec mode, change a little the script already used in the Basic Example.

test it now


Goon( "goon/1.1/exec/", "script.js",
	scr1: { file: "script1.js", mode: "exec" },
	scr2: "script2.js"
function() { 
	alert( "script" );

	var a = this.scr1.value;
	var b = this.scr2.value;
	var c = b - a;

	return { n1: a, n2: b, diff: c };
} );


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title> exec test </title>
<script type="text/javascript" src="goon-1.1.pack.js?base=http://noteslog.com/personal/projects/" id="g8n"></script>
<script type="text/javascript" src="exec/script1.js"></script>
<script type="text/javascript" src="exec/main.js"></script>
<p><a href="javascript:alert( 
);">test goon</a></p>
<p><a href="javascript:alert( 
);">test goony</a></p>

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”, “script1”, “script2”, “script”, “main”.

Here the first “script1” is alerted because it’s directly loaded into the page, the second “script1” 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, script1 has been loaded once, and its second entry in the goon repository is exporting a time different from the one exported by the first entry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.