lib/templates/loader.js
function scriptLoader(url, callback) {

			var doc         = document, s = doc.createElement("script")
			  , head        = doc.getElementsByTagName("head")[0]
			  , node
			  , done        = false;
			;

			// On success listener
			function onScriptLoad() {
				if ( !done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") )
				{
					done     = true;
					callback();
				}
			}

			// On failure listener (callback receive an error false)
			function onScriptError() {
				callback(new Error("Packet loading error for " + url));
			}

			// Create the script tag
			node         = document.createElement('script')
			node.type    = config.scriptType || 'text/javascript';
			node.charset = 'utf-8';
			node.async   = true;

			// Listen to the onload event
			if (node.attachEvent &&
					!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0)) {
				node.attachEvent('onreadystatechange', onScriptLoad);
			} else {
				node.addEventListener('load', onScriptLoad, false);
				node.addEventListener('error', onScriptError, false);
			}

			// Set the src value with the packed script url
			node.src = url;

			// Start loading by adding the script tag in the head
			head.appendChild(node);

		}
function scriptLoader(url, callback) {

			var doc         = document, s = doc.createElement("script")
			  , head        = doc.getElementsByTagName("head")[0]
			  , node
			  , done        = false;
			;

			// On success listener
			function onScriptLoad() {
				if ( !done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") )
				{
					done     = true;
					callback();
				}
			}

			// On failure listener (callback receive an error false)
			function onScriptError() {
				callback(new Error("Packet loading error for " + url));
			}

			// Create the script tag
			node         = document.createElement('script')
			node.type    = config.scriptType || 'text/javascript';
			node.charset = 'utf-8';
			node.async   = true;

			// Listen to the onload event
			if (node.attachEvent &&
					!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0)) {
				node.attachEvent('onreadystatechange', onScriptLoad);
			} else {
				node.addEventListener('load', onScriptLoad, false);
				node.addEventListener('error', onScriptError, false);
			}

			// Set the src value with the packed script url
			node.src = url;

			// Start loading by adding the script tag in the head
			head.appendChild(node);

		}
function scriptLoader ( url , callback ) { var doc = document , s = doc . createElement ( "script" ) , head = doc . getElementsByTagName ( "head" ) [ 0 ] , node , done = false ; ; // On success listener function onScriptLoad ( ) { if ( ! done && ( ! this . readyState || this . readyState == "loaded" || this . readyState == "complete" ) ) { done = true ; callback ( ) ; } } // On failure listener (callback receive an error false) function onScriptError ( ) { callback ( new Error ( "Packet loading error for " + url ) ) ; } // Create the script tag node = document . createElement ( 'script' ) node . type = config . scriptType || 'text/javascript' ; node . charset = 'utf-8' ; node . async = true ; // Listen to the onload event if ( node . attachEvent && ! ( node . attachEvent . toString && node . attachEvent . toString ( ) . indexOf ( '[native code' ) < 0 ) ) { node . attachEvent ( 'onreadystatechange' , onScriptLoad ) ; } else { node . addEventListener ( 'load' , onScriptLoad , false ) ; node . addEventListener ( 'error' , onScriptError , false ) ; } // Set the src value with the packed script url node . src = url ; // Start loading by adding the script tag in the head head . appendChild ( node ) ; }
The script loader

Load a packed script and return to the callback the resulting
value

@param  {string}   url      The packed script url
@param  {Function} callback A callback function that receive and error object
The script loader