4 ms·
For a larger web app, I'd use Require, Browserify, or Component, but not for small-to-medium size websites. All you usually need for those is jQuery, and severa
by ahallock 13y ago
For a larger web app, I'd use Require, Browserify, or Component, but not for small-to-medium size websites. All you usually need for those is jQuery, and several plugins which only depend on jQuery.
- delambo 13y agoI used to think the same thing, but then I ran into the problem where my large app had circular dependencies which require.js/AMD does not support. Naturally, AMD supporters blame you and your project's architecture, but it is not uncommon to have some circular dependencies in a large app. The work-around is to use require.js in commonjs style or to add hacks into your architecture. Not fun.
- williamcotton 13y agoCircular dependencies ARE a problem with your architecture. You've got two modules that are strongly coupled. They should either be in one module or you should rethink things. It is impossible to need one without the other in that case, so including one without the other makes no sense, so just merge them.
- pawrvx 13y agoIn large projects, and especially legacy ports, you don't have that luxury. Hence, careful selection of projects to work on is key.
- anaptdemise 13y ago> Circular dependencies ARE a problem with your architecture This whole thread reminds me of the PHP days before namespaces. If you have circular dependencies within your own codebase, you have an architecture problem. If they are introduced by third-party libraries, maybe the usage of the library should be questioned.
- delambo 13y agoHere's a trivial example: I have a Modal class which depends on some utilities in a Utility class, but the Utility class depends on the Modal class because there are some utilities that show Modals. This is not a broken architecture and is handled just fine by other programming languages/dependency handlers.
- williamcotton 13y agoThe concept of a "Utility Class" is normally a sign that there is something else going on! What are the utilities contained in this module?
- tretiy3 13y agoYou want to use inversion of control in your Utility class. Just pass function, which will operate on Modal class instance (not Modal class instance itself but function) as argument to its utilities that show Modals.
- protonfish 13y agoI have never worked on a large Web app that required an unmanageably large JavaScript code base. They were simply built with one due to 1. too much structural code, 2. cramming too much in one page, or 3. cramming too much in one site. All of these are mistakes of poor design and architecture and using require.js won't solve that problem. My current project uses require and after several months of working with the legacy code, I have not been convinced that it has improved maintainability. I would not use it again if given the choice.