dist/f2.basic.js
function(scripts, cb) {
			// Reduce the list to scripts that haven't been loaded
			var existingScripts = _findExistingScripts();
			var loadingScripts = Object.keys(_loadingScripts);
			scripts = jQuery.grep(scripts, function(url) {
				return url && (jQuery.inArray(url, existingScripts) === -1 || jQuery.inArray(url, loadingScripts) !== -1);
			});

			// Attempt to use the user provided method
			if (_config.loadScripts) {
				return _config.loadScripts(scripts, cb);
			}

			if (!scripts.length) {
				return cb();
			}

			var doc = window.document;
			var scriptCount = scripts.length;
			var scriptsLoaded = 0;
			//http://caniuse.com/#feat=script-async
			// var supportsAsync = 'async' in doc.createElement('script') || 'MozAppearance' in doc.documentElement.style || window.opera;
			var head = doc && (doc['head'] || doc.getElementsByTagName('head')[0]);
			// to keep IE from crying, we need to put scripts before any
			// <base> elements, but after any <meta>. this should do it:
			var insertBeforeEl = head && head.getElementsByTagName('base')[0] || null;
			// Check for IE10+ so that we don't rely on onreadystatechange, readyStates for IE6-9
			var readyStates = 'addEventListener' in window ? {} : { 'loaded': true, 'complete': true };

			// Log and emit event for the failed (400,500) scripts
			var _error = function(e) {
				setTimeout(function() {
					var evtData = {
						src: e.target.src,
						appId: appConfigs[0].appId
					};

					// Send error to console
					F2.log('Script defined in \'' + evtData.appId + '\' failed to load \'' + evtData.src + '\'');

					// TODO: deprecate, see #222
					F2.Events.emit(F2.Constants.Events.RESOURCE_FAILED_TO_LOAD, evtData);

					if (!_bUsesAppHandlers) {
						_appScriptLoadFailed(appConfigs[0], evtData.src);
					}
					else {
						F2.AppHandlers.__trigger(
							_sAppHandlerToken,
							F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED,
							appConfigs[0],
							evtData.src
						);
					}
				}, _config.scriptErrorTimeout); // Defaults to 7000
			};

			var _checkComplete = function() {
				// Are we done loading all scripts for this app?
				if (++scriptsLoaded === scriptCount) {
					// success
					cb();
				}
			};

			var _emptyWaitlist = function(resourceKey, errorEvt) {
				var waiting,
					waitlist = _loadingScripts[resourceKey];

				if (!waitlist) {
					return;
				}

				for (var i=0; i<waitlist.length; i++) {
					waiting = waitlist	[i];

					if (errorEvt) {
						waiting.error(errorEvt);
					} else {
						waiting.success();
					}
				}

				_loadingScripts[resourceKey] = null;
			};

			// Load scripts and eval inlines once complete
			jQuery.each(scripts, function(i, e) {
				var script = doc.createElement('script'),
					resourceUrl = e,
					resourceKey = resourceUrl.toLowerCase();

				// this script is actively loading, add this app to the wait list
				if (_loadingScripts[resourceKey]) {
					_loadingScripts[resourceKey].push({
						success: _checkComplete,
						error: _error
					});
					return;
				}

				// create the waitlist
				_loadingScripts[resourceKey] = [];

				// If in debugMode, add cache buster to each script URL
				if (_config.debugMode) {
					resourceUrl += '?cachebuster=' + new Date().getTime();
				}

				// Scripts are loaded asynchronously and executed in order
				// in supported browsers: http://caniuse.com/#feat=script-async
				script.async = false;
				script.type = 'text/javascript';
				script.charset = 'utf-8';

				script.onerror = function(e) {
					_error(e);
					_emptyWaitlist(resourceKey, e);
				};

				// Use a closure for the load event so that we can dereference the original script
				script.onload = script.onreadystatechange = function(e) {
					e = e || window.event; // For older IE

					// detect when it's done loading
					// ev.type == 'load' is for all browsers except IE6-9
					// IE6-9 need to use onreadystatechange and look for
					// el.readyState in {loaded, complete} (yes, we need both)
					if (e.type == 'load' || readyStates[script.readyState]) {
						// Done, cleanup
						script.onload = script.onreadystatechange = script.onerror = '';
						// increment and check if scripts are done
						_checkComplete();
						// empty wait list
						_emptyWaitlist(resourceKey);
						// Dereference script
						script = null;
					}
				};

				//set the src, start loading
				script.src = resourceUrl;

				//<head> really is the best
				head.insertBefore(script, insertBeforeEl);
			});
		}
function(scripts, cb) {
			// Reduce the list to scripts that haven't been loaded
			var existingScripts = _findExistingScripts();
			var loadingScripts = Object.keys(_loadingScripts);
			scripts = jQuery.grep(scripts, function(url) {
				return url && (jQuery.inArray(url, existingScripts) === -1 || jQuery.inArray(url, loadingScripts) !== -1);
			});

			// Attempt to use the user provided method
			if (_config.loadScripts) {
				return _config.loadScripts(scripts, cb);
			}

			if (!scripts.length) {
				return cb();
			}

			var doc = window.document;
			var scriptCount = scripts.length;
			var scriptsLoaded = 0;
			//http://caniuse.com/#feat=script-async
			// var supportsAsync = 'async' in doc.createElement('script') || 'MozAppearance' in doc.documentElement.style || window.opera;
			var head = doc && (doc['head'] || doc.getElementsByTagName('head')[0]);
			// to keep IE from crying, we need to put scripts before any
			// <base> elements, but after any <meta>. this should do it:
			var insertBeforeEl = head && head.getElementsByTagName('base')[0] || null;
			// Check for IE10+ so that we don't rely on onreadystatechange, readyStates for IE6-9
			var readyStates = 'addEventListener' in window ? {} : { 'loaded': true, 'complete': true };

			// Log and emit event for the failed (400,500) scripts
			var _error = function(e) {
				setTimeout(function() {
					var evtData = {
						src: e.target.src,
						appId: appConfigs[0].appId
					};

					// Send error to console
					F2.log('Script defined in \'' + evtData.appId + '\' failed to load \'' + evtData.src + '\'');

					// TODO: deprecate, see #222
					F2.Events.emit(F2.Constants.Events.RESOURCE_FAILED_TO_LOAD, evtData);

					if (!_bUsesAppHandlers) {
						_appScriptLoadFailed(appConfigs[0], evtData.src);
					}
					else {
						F2.AppHandlers.__trigger(
							_sAppHandlerToken,
							F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED,
							appConfigs[0],
							evtData.src
						);
					}
				}, _config.scriptErrorTimeout); // Defaults to 7000
			};

			var _checkComplete = function() {
				// Are we done loading all scripts for this app?
				if (++scriptsLoaded === scriptCount) {
					// success
					cb();
				}
			};

			var _emptyWaitlist = function(resourceKey, errorEvt) {
				var waiting,
					waitlist = _loadingScripts[resourceKey];

				if (!waitlist) {
					return;
				}

				for (var i=0; i<waitlist.length; i++) {
					waiting = waitlist	[i];

					if (errorEvt) {
						waiting.error(errorEvt);
					} else {
						waiting.success();
					}
				}

				_loadingScripts[resourceKey] = null;
			};

			// Load scripts and eval inlines once complete
			jQuery.each(scripts, function(i, e) {
				var script = doc.createElement('script'),
					resourceUrl = e,
					resourceKey = resourceUrl.toLowerCase();

				// this script is actively loading, add this app to the wait list
				if (_loadingScripts[resourceKey]) {
					_loadingScripts[resourceKey].push({
						success: _checkComplete,
						error: _error
					});
					return;
				}

				// create the waitlist
				_loadingScripts[resourceKey] = [];

				// If in debugMode, add cache buster to each script URL
				if (_config.debugMode) {
					resourceUrl += '?cachebuster=' + new Date().getTime();
				}

				// Scripts are loaded asynchronously and executed in order
				// in supported browsers: http://caniuse.com/#feat=script-async
				script.async = false;
				script.type = 'text/javascript';
				script.charset = 'utf-8';

				script.onerror = function(e) {
					_error(e);
					_emptyWaitlist(resourceKey, e);
				};

				// Use a closure for the load event so that we can dereference the original script
				script.onload = script.onreadystatechange = function(e) {
					e = e || window.event; // For older IE

					// detect when it's done loading
					// ev.type == 'load' is for all browsers except IE6-9
					// IE6-9 need to use onreadystatechange and look for
					// el.readyState in {loaded, complete} (yes, we need both)
					if (e.type == 'load' || readyStates[script.readyState]) {
						// Done, cleanup
						script.onload = script.onreadystatechange = script.onerror = '';
						// increment and check if scripts are done
						_checkComplete();
						// empty wait list
						_emptyWaitlist(resourceKey);
						// Dereference script
						script = null;
					}
				};

				//set the src, start loading
				script.src = resourceUrl;

				//<head> really is the best
				head.insertBefore(script, insertBeforeEl);
			});
		}
function ( scripts , cb ) { // Reduce the list to scripts that haven't been loaded var existingScripts = _findExistingScripts ( ) ; var loadingScripts = Object . keys ( _loadingScripts ) ; scripts = jQuery . grep ( scripts , function ( url ) { return url && ( jQuery . inArray ( url , existingScripts ) === - 1 || jQuery . inArray ( url , loadingScripts ) !== - 1 ) ; } ) ; // Attempt to use the user provided method if ( _config . loadScripts ) { return _config . loadScripts ( scripts , cb ) ; } if ( ! scripts . length ) { return cb ( ) ; } var doc = window . document ; var scriptCount = scripts . length ; var scriptsLoaded = 0 ; //http://caniuse.com/#feat=script-async // var supportsAsync = 'async' in doc.createElement('script') || 'MozAppearance' in doc.documentElement.style || window.opera; var head = doc && ( doc [ 'head' ] || doc . getElementsByTagName ( 'head' ) [ 0 ] ) ; // to keep IE from crying, we need to put scripts before any // <base> elements, but after any <meta>. this should do it: var insertBeforeEl = head && head . getElementsByTagName ( 'base' ) [ 0 ] || null ; // Check for IE10+ so that we don't rely on onreadystatechange, readyStates for IE6-9 var readyStates = 'addEventListener' in window ? { } : { 'loaded' : true , 'complete' : true } ; // Log and emit event for the failed (400,500) scripts var _error = function ( e ) { setTimeout ( function ( ) { var evtData = { src : e . target . src , appId : appConfigs [ 0 ] . appId } ; // Send error to console F2 . log ( 'Script defined in \'' + evtData . appId + '\' failed to load \'' + evtData . src + '\'' ) ; // TODO: deprecate, see #222 F2 . Events . emit ( F2 . Constants . Events . RESOURCE_FAILED_TO_LOAD , evtData ) ; if ( ! _bUsesAppHandlers ) { _appScriptLoadFailed ( appConfigs [ 0 ] , evtData . src ) ; } else { F2 . AppHandlers . __trigger ( _sAppHandlerToken , F2 . Constants . AppHandlers . APP_SCRIPT_LOAD_FAILED , appConfigs [ 0 ] , evtData . src ) ; } } , _config . scriptErrorTimeout ) ; // Defaults to 7000 } ; var _checkComplete = function ( ) { // Are we done loading all scripts for this app? if ( ++ scriptsLoaded === scriptCount ) { // success cb ( ) ; } } ; var _emptyWaitlist = function ( resourceKey , errorEvt ) { var waiting , waitlist = _loadingScripts [ resourceKey ] ; if ( ! waitlist ) { return ; } for ( var i = 0 ; i < waitlist . length ; i ++ ) { waiting = waitlist [ i ] ; if ( errorEvt ) { waiting . error ( errorEvt ) ; } else { waiting . success ( ) ; } } _loadingScripts [ resourceKey ] = null ; } ; // Load scripts and eval inlines once complete jQuery . each ( scripts , function ( i , e ) { var script = doc . createElement ( 'script' ) , resourceUrl = e , resourceKey = resourceUrl . toLowerCase ( ) ; // this script is actively loading, add this app to the wait list if ( _loadingScripts [ resourceKey ] ) { _loadingScripts [ resourceKey ] . push ( { success : _checkComplete , error : _error } ) ; return ; } // create the waitlist _loadingScripts [ resourceKey ] = [ ] ; // If in debugMode, add cache buster to each script URL if ( _config . debugMode ) { resourceUrl += '?cachebuster=' + new Date ( ) . getTime ( ) ; } // Scripts are loaded asynchronously and executed in order // in supported browsers: http://caniuse.com/#feat=script-async script . async = false ; script . type = 'text/javascript' ; script . charset = 'utf-8' ; script . onerror = function ( e ) { _error ( e ) ; _emptyWaitlist ( resourceKey , e ) ; } ; // Use a closure for the load event so that we can dereference the original script script . onload = script . onreadystatechange = function ( e ) { e = e || window . event ; // For older IE // detect when it's done loading // ev.type == 'load' is for all browsers except IE6-9 // IE6-9 need to use onreadystatechange and look for // el.readyState in {loaded, complete} (yes, we need both) if ( e . type == 'load' || readyStates [ script . readyState ] ) { // Done, cleanup script . onload = script . onreadystatechange = script . onerror = '' ; // increment and check if scripts are done _checkComplete ( ) ; // empty wait list _emptyWaitlist ( resourceKey ) ; // Dereference script script = null ; } } ; //set the src, start loading script . src = resourceUrl ; //<head> really is the best head . insertBefore ( script , insertBeforeEl ) ; } ) ; }
For loading AppManifest.scripts Parts derived from curljs, headjs, requirejs, dojo
For loading AppManifest . scripts Parts derived from curljs headjs requirejs dojo