curl-amd
Version:
curl.js is small, fast, extensible module loader that handles AMD, CommonJS Modules/1.1, CSS, HTML/text, and legacy scripts.
50 lines (39 loc) • 1.12 kB
HTML
<html>
<head>
<title>CommonJS Modules 1.1 loading test</title>
<script>
curl = {
paths: {
curl: '../src/curl',
commonjs: 'support/commonjs'
}
};
</script>
<script src="../src/curl.js" type="text/javascript"></script>
<script type="text/javascript">
curl(
[
// test modules:
'commonjs/exports',
'commonjs/this',
'commonjs/hybrid'
]
).then(
function (exports, thisModule, hybrid) {
write('A module that exports properties loaded successfully if "it works" == ' + exports.testMessage + '.');
write('A module that exports as `this` loaded successfully if "it works" == ' + thisModule.testMessage + '.');
write('A module that inspects `require("module")` loaded successfully if "commonjs/module" == ' + hybrid.foo().testMessage + '.');
write('A module that exposes its module info loaded successfully if this "commonjs/this" == ' + thisModule._module.id + '.');
}
);
function write (msg) {
curl('domReady!', function () {
document.body.appendChild(document.createElement('div')).innerHTML = msg;
});
}
</script>
</head>
<body>
</body>
</html>