Moff.amd

This module provides Asynchronous Module Definition technique to load modules and their dependencies if desired.

include(id, callback, options)

Loads registered module by id.

Arguments:

id - Module identifier.
[callback] - Function which will be executed when all registered file be loaded. Callback will be executed immediately if module was included before.
[options] - Object with include parameters:
reload - Re-include all registered file, even they were included before.

Moff.amd.include('liveChat', function() {}, {reload: true});

register(object)

Register module (simple object) to be loaded later.

Arguments:

object - Object with the following properties:
id - Module identifier
depend - Optional dependency object of module. Consists from js and css keys:
js - Array of javascript files.
css - Array of css files.
file - Object of module main files. Consists from js and css keys:
js - Array of javascript files.
css - Array of css files.
beforeInclude - Optional callback to be triggered before all files include.
afterInclude - Optional callback to be triggered after all files include.
loadOnScreen - Optional array of screen sizes which indicates when module will be loaded automatically.
onWindowLoad - Optional boolean which determines whether module will be loaded on window load event.

Moff.amd.register({
	id: 'liveChat',
	depend: {
		js: ['http://chat-domain.com/js/chat-api.js'],
		css: ['http://chat-domain.com/css/chat.css']
	},
	file: {
		js: ['modules/my-chat.js'],
		css: ['modules/my-chat.css']
	},

	beforeInclude: function() {},
	afterInclude: function() {},
	loadOnScreen: ['md', 'lg'],
	onWindowLoad: true
});