Last active
August 29, 2015 14:02
-
-
Save sjmiles/af9d353690758ac9ee42 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
// irand.html | |
<script> | |
modularize(function() { | |
// whatever we return constitutes our `module` | |
return function(n) { | |
return Math.floor(Math.random() * n); | |
} | |
}); | |
</script> | |
// text.html | |
<!-- imports handle dependency management and network access --> | |
<link rel="import" href="irand.html"> | |
<script> | |
// create a module that uses 'irand' | |
modularize(['irand'], function(irand) { | |
// whatever we return constitutes our `module` | |
return { | |
get text() { | |
return ['Ahoy-hoy', 'Excellent', 'Gyrocopter to Siam'][irand(3)]; | |
} | |
} | |
}); | |
</script> | |
// index.html | |
<link rel="import" href="text.html"> | |
<script> | |
using(['text'], function(text) { | |
document.write(text.text); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment