Skip to content
69 lines (65 sloc) 1.65 KB
<!doctype html>
<head>
<style>
body {
background: blue;
color: #fff;
}
pre {
color: black;
background: white;
}
</style>
</head>
<body>
<div role="main">
<h1>Module Loader Polyfill</h1>
<p>Check the console in your browser developer tools! This code is currently loaded in the page:</p>
<pre>
&lt;script src="../node_modules/traceur/bin/traceur.js">&lt;/script>
&lt;script src="../dist/es6-module-loader-dev.js">&lt;/script>
&lt;script type="module">
import { hello } from 'test1.js';
console.log(hello); // -> world
// es6 syntax
var a, b;
[a, b] = [1, 2];
console.log(a); // 1
&lt;/script>
</pre>
<p>Click on the button below and this function will be run:</p>
<pre>
&lt;script>
function buttonClick() {
// dynamic loading API
System.import('test2.js').then(function(module) {
new module.Foo();
});
}
&lt;/script>
</pre>
<button onclick="buttonClick()">Load test2</button>
<p>Note that if you click on the button again, a new Foo module will be created, but 'test2' will not be reloaded.</p>
</div>
<footer>
</footer>
<script src="../node_modules/traceur/bin/traceur.js"></script>
<script src="../dist/es6-module-loader-dev.js"></script>
<script type="module">
import { hello } from 'test1.js';
console.log(hello); // -> world
// es6 syntax
var a, b;
[a, b] = [1, 2];
console.log(a); // -> 1
</script>
<script>
function buttonClick() {
// dynamic loading API
System.import('test2.js').then(function(module) {
new module.Foo();
});
}
</script>
</body>
</html>
Something went wrong with that request. Please try again.