NBL tests

by fergal_doyle

HTML

<script src="//raw.github.com/berklee/nbl/master/nbl.plus.min.js"></script>

JavaScript

nbl.l(["http://code.jquery.com/jquery-1.9.1.min.js", function(){

    console.log("jquery downloaded");
    console.log(nbl.q);

    nbl.l(["http://code.jquery.com/jquery-1.9.1.min.js"])
    
}])


/*
 * NBL: Non Blocking Lazy loader v2.0
 * Copyright (c) 2010 Berklee. Additional input from Knowlecules. CSS callback bug fix, additional code reduction by Richard Lopes.
 * Licensed under the MIT license.
 *
 * Date: 2010-09-24
 */
nbl = {
	c: document,
	q: {}, // The dictionary that will hold the script-queue
	n: null,
	
	// The loader function
	//
	// Called with an array, it will interpret the options array
	// Called without an array it will try to load the options from the script-tag's data-nbl attribute
	l: function(a) { 
		var b, c, x, y, z, s, l, i = j = 0, m = this; m.h = m.c.head || m.c.body || m.c.documentElement || m.h;
		
		// The timeout counter, counts backwards every 50ms from 50 ticks (50*50=2500ms by default)
		if (!m.i) {
			m.s = m.f = 0; // Reset counters: completed, created, timeout function
			m.i = setInterval(
				function() { 
					// If the timeout counter dips below zero, or the amount of completed scripts equals the amount 
					// of created script-tags, we can clear the interval
					if (m.o < 0 || m.s == 0) { 
						m.i = clearInterval(m.i); 
						// If the amount of completed scripts is smaller than the amount of created script-tags,
						// and there is a timeout function available, call it with the current script-queue.
						(m.s > 0 && m.f) && m.f(m.q)
					} 
					m.o--
				},
				m.o = 50 // Set the initial ticks at 50, as well as the interval at 50ms
			);
		}

		// If no arguments were given (a == l, which is null), try to load the options from the script tag
		if (a == m.n) {
			s = m.c.getElementsByTagName("script"); // Get all script tags in the current document
			while (j < s.length) {
				if ((a = eval("("+s[j].getAttribute("data-nbl")+")")) && a) { // Check for the data-nbl attribute
					m.h =...