You can try something similar to this script and use the internal API onResourceLoad
. This will not give a completely accurate load time, but it will give you an idea of ββwhich modules were requested and how long after a given start time they were loaded.
<script>
require = {
paths: {
"jquery": "http://code.jquery.com/jquery-2.0.3",
"underscore": "http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min"
},
shim: {
"underscore": {
deps: ["jquery"],
exports: "_"
}
}
};
</script>
<script src="http://requirejs.org/docs/release/2.1.8/comments/require.js"></script>
<script>
requirejs.onResourceLoad = function(context, map, depArray) {
var duration = new Date() - start;
console.log("onResourceLoad", duration + "ms", map.id);
}
</script>
and this is js
start = +new Date();
require(["jquery", "underscore"], function() {
console.log("require.s.contexts._.defined", require.s.contexts._.defined);
});
Produces this output in a test:
onResourceLoad 140ms jquery
onResourceLoad 167ms underscore
require.s.contexts._.defined Object {jquery: function, underscore: function}
source
share