Im just in the middle of refactoring my javascript into a modular fashion using requireJS.
I have finished and my project structure looks sweet dont get me wrong. But now publishing the app up to windows azure it now runs like a dog. Pages pop up quick but they clunk quite a bit as the dependencies on the requirejs modules e in and take effect.
Am I doing something wrong? I thought this would smooth out the loading of everything.
Has anyone e across this dilemma where they wanted modular fashioned javascript and tried to acplish this with requireJs and got a bad result?
Thanks in advance
Im just in the middle of refactoring my javascript into a modular fashion using requireJS.
I have finished and my project structure looks sweet dont get me wrong. But now publishing the app up to windows azure it now runs like a dog. Pages pop up quick but they clunk quite a bit as the dependencies on the requirejs modules e in and take effect.
Am I doing something wrong? I thought this would smooth out the loading of everything.
Has anyone e across this dilemma where they wanted modular fashioned javascript and tried to acplish this with requireJs and got a bad result?
Thanks in advance
Share Improve this question asked Aug 7, 2012 at 6:07 MattMatt 2,86311 gold badges58 silver badges102 bronze badges1 Answer
Reset to default 8What do you mean by a bad result? Has the initial page load time reduced drastically after implementing require js? If so, do you understand why it has happened?
What I mean is, without minification/concatenation having played any part in the reduction of load time, the initial page load time reduces as you might be making a request for only one js file, the require js loader and the main.js ... all your other dependencies that were loaded before dom ready are now being loaded on first use after dom ready.
You may want to read http://requirejs/docs/optimization.html for a way to minify/concatenate the files.
EDIT: if all you want is modular js, you can simply use something like the Revealing Module Pattern, RequireJS helps with the dependency management. Without RequireJS you would have to manually ensure that all your dependencies are loaded before you module code executes.