Skip to content

Instantly share code, notes, and snippets.

@cowlby
Created October 26, 2009 05:07
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 cowlby/218423 to your computer and use it in GitHub Desktop.
Save cowlby/218423 to your computer and use it in GitHub Desktop.
// Nano Loader
(function() {
nano = {
v: "1.0",
load: function(u, cb) {
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = u;
s.onload = cb;
s.onreadystatechange = function() {
if (this.readyState == 'complete' || this.readyState == 'loaded') { cb(); }
};
document.getElementsByTagName('head')[0].appendChild(s);
},
mt: function(cb) {
if (typeof(MooTools)=="undefined") {nano.load('http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-yui-compressed.js', cb);}
},
jq: function(cb) {
if (typeof(jQuery)=="undefined") {nano.load('http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', cb);}
}
};
})();
// Bookmarklet
javascript:(function(){nano={v:"1.0",load:function(u,cb){var s=document.createElement('script');s.type='text/javascript';s.src=u;s.onload=cb;s.onreadystatechange=function(){if(this.readyState=='complete'||this.readyState=='loaded'){cb();}};document.getElementsByTagName('head')[0].appendChild(s);},mt:function(cb){if(typeof(MooTools)=="undefined"){nano.load('http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-yui-compressed.js',cb);}},jq:function(cb){if(typeof(jQuery)=="undefined"){nano.load('http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js',cb);}}};})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment