Hacker News new | ask | show | jobs
by TimFogarty 4505 days ago
What are the supposed benefits of using module loaders over say minifying and concatenating all your JS into one maybe two files which are then placed in script tags at the bottom of your HTML?
2 comments

- Organized code (into modules)

- Explicit dependencies (instead of using the global scope for communication)

- Easier to reason about and test parts of the code

- Errors are properly isolated in a module

The post is putting module loaders (requirejs) and "using modules" (e.g. commonjs) into the same box. With browserify you end up with one or maybe two large concatenated file that you then place in script tags at the bottom of your HTML. There's no "instead".

There is a distinction to be made between having a module system, and how those modules are loaded. You can still concatenate everything together while using a module loading system, you just don't need to load the modules individually in that case.

One potential problem with concatenating everything without modules is that you then need to maintain your concatenation order based on dependencies using some other system. To his second point, you can certainly do this perfectly easily on smaller apps, but it becomes impossible as systems grow.