Skip to content

Instantly share code, notes, and snippets.

@rekkusu
Forked from KOBA789/load.js
Created August 17, 2011 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rekkusu/1151837 to your computer and use it in GitHub Desktop.
Save rekkusu/1151837 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?document.body:document.getElementsByTagName("head")[0]).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