module template:
var myModule = (function(exports){
var x = "foo";
exports.myFunction = function(){
alert(x);
};
})(typeof exports!="undefined" && exports instanceof Object ? exports : window );
myFunctionwill be available in the area windowin the browser.
EDIT
I quote the author: "I also call these functions from a separate HTML page."
therefore, the author needs global access to the functions he defines.
var myModule is not needed, although it is not exported, it is just for compatibility with AMD:
(function(exports){
var x = "foo";
exports.myFunction = function(){
alert(x);
};
})(window);
x myFunction , myFunction x . x - x = "foo"