Reputation: 3271
We are using lots of libraries and I'm looking in to require.js which looks great. You can manage your dependencies and divide your code into modular structure.
I'm not able to understand how this works on production? On production you minify and merge all js to one file. There is only one js file that loads everything, so how requirejs is useful?
Upvotes: 2
Views: 96
Reputation: 119847
Because production isn't the only step in software development. Just like how it has always been in software development, it's better to modularize code for readability and maintenance and development.
An simple comparison would be that of other languages. If it were Java, you wouldn't want all your classes in one file now would you? You'd always break every class into separate files. But in the end, they get compiled for production.
Upvotes: 3
Reputation: 7471
Actually on production people have a lot of js-files, not only one. For example, look at the head section of stackoverflow.com page.
Upvotes: 0
Reputation: 236022
requireJS ships with r.js adapter for Node and Rhino
, which pretty much does the resolving and injecting of dependencies statically, and creates/outputs your production file.
Read more: http://requirejs.org/docs/optimization.html
Upvotes: 3