Skip to content

Instantly share code, notes, and snippets.

@KOBA789
Created August 17, 2011 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save KOBA789/1151230 to your computer and use it in GitHub Desktop.
Save KOBA789/1151230 to your computer and use it in GitHub Desktop.
なにかひどいなにか
var load = new (function () {
var count = 0;
var next = function () {}
var callback = function () {
count --;
if (count <= 0) {
next();
}
}
self = this;
this.load = function (src) {
count ++;
var scriptElement = document.createElement('script');
scriptElement.type = 'text/javascript';
scriptElement.onload = callback;
scriptElement.src = src;
document.body.appendChild(scriptElement);
return self;
}
this.then = function (callback) {
next = callback;
}
})().load;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment