multiple require instances
HTML
<script src="http://requirejs.org/docs/release/2.1.9/comments/require.js"></script>
<script>
var texts = [];
function textLoaded(text) {
for (var i = 0; i < texts.length; i++) {
var msg = "New text matches text[" + i + "] ";
msg += (text === texts[i]);
console.log(msg);
}
texts.push(text);
}
</script>
<script>
// It is important to give the config objects a "context" name.
// This is what keeps them unique.
var r1 = require.config({
context: "r1",
baseUrl: "//rawgithub.com/requirejs/text/2.0.10/"
});
var r2 = require.config({
context: "r2",
baseUrl: "//rawgithub.com/requirejs/text/2.0.10/"
//baseUrl: "//cdnjs.cloudflare.com/ajax/libs/require-text/2.0.10/"
});
console.log("r2 === r1", r2 === r1);
</script>
<script>
r1(["require", "text"], function(r, text) {
textLoaded(text);
});
r2(["require", "text"], function(r, text) {
textLoaded(text);
});
</script>