Skip to content

Instantly share code, notes, and snippets.

@brikis98
Forked from jakobo/increment.js
Created February 11, 2012 01:04
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 brikis98/1794839 to your computer and use it in GitHub Desktop.
Save brikis98/1794839 to your computer and use it in GitHub Desktop.
var getName = require('name').getName;
exports.hello = function() {
return "Hello " + getName();
};
<script type="text/javascript" src="/js/inject.js"></script>
<script type="text/javascript">
require.setModuleRoot("http://example.com/js/modules");
require.run("program");
</script>
<script type="text/javascript" src="/js/modules/name.js"></script>
<script type="text/javascript" src="/js/modules/hello.js"></script>
<script type="text/javascript" src="/js/modules/program.js"></script>
exports.getName = function() {
return prompt("What's your name?");
};
var hello = require('hello').hello;
alert(hello());
@brikis98
Copy link
Author

@Serpenthelm: I believe Inject uses XHR to fetch JS files, so you need a valid domain. This means running locally, without a server, won't work, since a file:/// path is probably not going to be recognized as a valid domain. @jakobo could comment more, but I think you'll need to fire up some sort of server (e.g. apache) to test so you can use localhost as a domain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment