Skip to content

Instantly share code, notes, and snippets.

@kentaromiura
Created February 25, 2010 17:41
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 kentaromiura/314797 to your computer and use it in GitHub Desktop.
Save kentaromiura/314797 to your computer and use it in GitHub Desktop.
var require =(function(){
var imports = new Hash();
var path = "libs"
return function(lib){
if(!imports.has(lib)){
var req = new Request({
url:[path,lib].join('/') + ".js",
async:false
});
req.send('');
imports.set(lib,eval(['(function(){var exports={},module={name:"',lib,'"};',req.xhr.responseText,';return exports;})()'].join('')));
}
return imports[lib];
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment