It sure makes a lot of sense to write modular, independent testable code – especially for big projects.
But what difference does using require.js/amd make in a big project where I still need to concenate & minify my project on build?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would like to preface my response with saying that I do think Require.JS is an utterly useless framework. It over-complicates a fairly simple concept.
That being said, dependency loading is VERY useful when it comes to writing platform independent code.
For example, say you wanted to develop a web application that you can also port into Apache Cordova for mobile apps and into AppJS for desktop apps. You wouldn’t want to rewrite all of your business logic, so it makes sense to build a bootstrap that loads dependencies dynamically to adapt the software to multiple architectures. That way you only have one product, which is able to run on a variety of platforms. Add in the usage of NodeJS for server side script and you can not only write front end software, but back end with the exact same code.
Modularity helps a lot with cross-platform projects, but as I said: Require.JS really isn’t that useful. I have found it to be overly complicated. Instead, I just use an object built around jQuery’s getScript function that contains a registry of all loaded packages so that a dev doesn’t try to load a package that has already been loaded (larger projects).