exec mode

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

test it now

script:

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 };
} );

page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<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>
</head>
<body>
<p><a href="javascript:alert( 
goon['http://noteslog.com/personal/projects/goon/1.1/exec/main.js']
.exported.msg 
);">test goon</a></p>
<p><a href="javascript:alert( 
goony.msg
);">test goony</a></p>
</body>
</html>

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.

exec.png

exec2.png

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.