aboutsummaryrefslogtreecommitdiffstats
path: root/test/data/readywaitloader.js
blob: 8f4a3452ef7d1ae27a87ae804163923b8521fab2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Simple script loader that uses jQuery.readyWait via jQuery.holdReady()

//Hold on jQuery!
jQuery.holdReady( true );

var readyRegExp = /^(complete|loaded)$/;

function assetLoaded( evt ) {
	var node = evt.currentTarget || evt.srcElement;
	if ( evt.type === "load" || readyRegExp.test( node.readyState ) ) {
		jQuery.holdReady( false );
	}
}

setTimeout( function() {
	var script = document.createElement( "script" );
	script.type = "text/javascript";
	if ( script.addEventListener ) {
		script.addEventListener( "load", assetLoaded, false );
	} else {
		script.attachEvent( "onreadystatechange", assetLoaded );
	}
	script.src = "data/readywaitasset.js";
	document.getElementsByTagName( "head" )[ 0 ].appendChild( script );
}, 2000 );