I currently working on a Javascript application that's using multiple javascript file with a "module pattern". Like so:
var app = app || {};
app.moduleName = app.moduleName || {};
app.moduleName = function () {
// private property
var someProp = null;
return {
// public method
init: function () {
return "foo";
}
};
}();
The reason why im using this is to structurize my code. I can call a method or property by just calling app.moduleName.init() for example.
One downside of this is that I must include lots of <script src="app.moduleName.js">.. etc in my HTML.
To solve this problem, I came across RequireJS, I read the documentation. But I'm not quite sure how to merge this in my existing structure, without adding bunch of code to the existing javascript files.
Does somebody have any suggestion how to accomplish this?