cq-prolyfill.js
function loadExternal(href, callback) {
	var cacheEntryType = typeof requestCache[href];
	if (cacheEntryType === 'string') {
		callback(requestCache[href]);
		return;
	}
	else if (cacheEntryType === 'object') {
		requestCache[href].push(callback);
		return;
	}
	requestCache[href] = [callback]
	var isDone = false;
	var done = function(response) {
		if (!isDone) {
			response = response || '';
			requestCache[href].forEach(function(cachedCallback) {
				setTimeout(function() {
					cachedCallback(response);
				});
			});
			requestCache[href] = response;
		}
		isDone = true;
	};
	var xhr = new XMLHttpRequest();
	xhr.onreadystatechange = function() {
		if (xhr.readyState !== 4) {
			return;
		}
		done(xhr.status === 200 && xhr.responseText);
	};
	try {
		xhr.open('GET', href);
		xhr.send();
	}
	catch(e) {
		if (window.XDomainRequest) {
			xhr = new XDomainRequest();
			xhr.onprogress =
				/* istanbul ignore next: fix for a rare IE9 bug */
				function() {};
			xhr.onload = xhr.onerror = xhr.ontimeout = function() {
				done(xhr.responseText);
			};
			try {
				xhr.open('GET', href);
				xhr.send();
			}
			catch(e2) {
				done();
			}
		}
		else {
			done();
		}
	}
}
function loadExternal(href, callback) {
	var cacheEntryType = typeof requestCache[href];
	if (cacheEntryType === 'string') {
		callback(requestCache[href]);
		return;
	}
	else if (cacheEntryType === 'object') {
		requestCache[href].push(callback);
		return;
	}
	requestCache[href] = [callback]
	var isDone = false;
	var done = function(response) {
		if (!isDone) {
			response = response || '';
			requestCache[href].forEach(function(cachedCallback) {
				setTimeout(function() {
					cachedCallback(response);
				});
			});
			requestCache[href] = response;
		}
		isDone = true;
	};
	var xhr = new XMLHttpRequest();
	xhr.onreadystatechange = function() {
		if (xhr.readyState !== 4) {
			return;
		}
		done(xhr.status === 200 && xhr.responseText);
	};
	try {
		xhr.open('GET', href);
		xhr.send();
	}
	catch(e) {
		if (window.XDomainRequest) {
			xhr = new XDomainRequest();
			xhr.onprogress =
				/* istanbul ignore next: fix for a rare IE9 bug */
				function() {};
			xhr.onload = xhr.onerror = xhr.ontimeout = function() {
				done(xhr.responseText);
			};
			try {
				xhr.open('GET', href);
				xhr.send();
			}
			catch(e2) {
				done();
			}
		}
		else {
			done();
		}
	}
}
function loadExternal ( href , callback ) { var cacheEntryType = typeof requestCache [ href ] ; if ( cacheEntryType === 'string' ) { callback ( requestCache [ href ] ) ; return ; } else if ( cacheEntryType === 'object' ) { requestCache [ href ] . push ( callback ) ; return ; } requestCache [ href ] = [ callback ] var isDone = false ; var done = function ( response ) { if ( ! isDone ) { response = response || '' ; requestCache [ href ] . forEach ( function ( cachedCallback ) { setTimeout ( function ( ) { cachedCallback ( response ) ; } ) ; } ) ; requestCache [ href ] = response ; } isDone = true ; } ; var xhr = new XMLHttpRequest ( ) ; xhr . onreadystatechange = function ( ) { if ( xhr . readyState !== 4 ) { return ; } done ( xhr . status === 200 && xhr . responseText ) ; } ; try { xhr . open ( 'GET' , href ) ; xhr . send ( ) ; } catch ( e ) { if ( window . XDomainRequest ) { xhr = new XDomainRequest ( ) ; xhr . onprogress = /* istanbul ignore next: fix for a rare IE9 bug */ function ( ) { } ; xhr . onload = xhr . onerror = xhr . ontimeout = function ( ) { done ( xhr . responseText ) ; } ; try { xhr . open ( 'GET' , href ) ; xhr . send ( ) ; } catch ( e2 ) { done ( ) ; } } else { done ( ) ; } } }
Load external file via AJAX

@param {string}           href
@param {function(string)} callback Gets called with the response text on
success or empty string on failure
Load external file via AJAX