Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RequireJS slowed down the load of my web app

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 come in and take effect.

Am I doing something wrong? I thought this would smooth out the loading of everything.

Has anyone come across this dilemma where they wanted modular fashioned javascript and tried to accomplish this with requireJs and got a bad result?

Thanks in advance

like image 371
Matt Avatar asked Feb 20 '23 14:02

Matt


1 Answers

What 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.org/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.

like image 59
Amith George Avatar answered Feb 27 '23 01:02

Amith George