Created
October 17, 2012 20:52
-
-
Save konsumer/3908104 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
</head> | |
<body> | |
</body> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> | |
<script> | |
window.imported={}; | |
// synchronous require for CommonJS | |
function require(name){ | |
if (!window.imported[name]){ | |
$.ajax(name + '.js', { | |
cache: false, | |
async:false, | |
success: function(data, textStatus, jqXHR){ | |
window.imported[name] = new Function('var exports={};' + data + ';return exports;')(); | |
}, | |
error: function(jqXHR, textStatus, errorThrown){ | |
window.imported[name] = false; | |
console.error(errorThrown); | |
} | |
}); | |
} | |
return window.imported[name]; | |
} | |
var fib = require('../janrain/fib'); | |
console.log(fib.fib(4000)); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment