Answer the question
In order to leave comments, you need to log in
Does requirejs speed up script loading times?
Hello! I recently started getting familiar with require.js. AMD - asynchrony. In my understanding, this implies independent loading of modules (js scripts). In other words, parallel. But here's what I saw in chrome dev tools:
With the usual connection of scripts in the footer:
<script type="text/javascript" src="templates/js/new/jquery-ui-1.10.3.custom.min.js"></script>
<script type="text/javascript" src="templates/js/new/eventTrackerManager.v.1.0.js"></script>
<script type="text/javascript" src="templates/js/new/constants.js"></script>
<script type="text/javascript" src="templates/js/new/utils.js"></script>
require.config({
baseUrl: "templates/js/new/",
paths: {
"jQuery": "lib/jquery-2.0.3.min",
"jQueryUI" : "lib/jquery-ui-1.10.3.custom.min",
"Utils" : "modules/utils",
"contactform" : "modules/contactform"
...
},
shim: {
"jQueryUI": {
exports: "$",
deps: ['jQuery']
}
}
});
require(["contactform"], function(CF) {
CF.init();
});
Answer the question
In order to leave comments, you need to log in
requirejs works in the same way in parallel, but it loads dependent scripts after it executes the next script and finds out what needs to be loaded next. In order to avoid this, various techniques are used, such as precompilation. Read more here habrahabr.ru/post/181536/.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question