Javascript Require.js dependencies
dependencies, javascript, requirejs
Solution
C.js will only be loaded once, as long as it's loaded using the same name in A.js amd B.js.
Another useful thing you can do is as follows:
require.config({
"paths": {
"C": "/somewhere/js/C-v1.0.0.js"
}
});
If you then require A and B, in A and B you can:
require(["C"], function(C) {
}
This way, if the location or version of C changes, you only have to change it in one place.
Problem
if I have 2 .js files (A.js, B.js) and each of them has their own dependencies. A depends on: C.js, D.js, E.js B depends on: C.js, F.js, G.js A and B have C as common dependency. If both A and B are loaded with Require.js, will the C.js be loaded twice?