I need to create a web page for Basil’s WebGL version so I started looking at the JavaScript world. For a humorous and insightful take on what I’m getting into, read How It Feels to Learn JavaScript in 2016.

I want to include modularized files and, since I had experience with NodeJS modules, I figured I would just need to add a few require()s to my program.

That’s not the case.

While NodeJS has a (relatively) simple require() for appliction module inclusion, the reigning solution on the browser side is RequireJS. Coming from NodeJS’s implementation, RequireJS is a complex and confusing wall of specifications. Using RequireJS means a different wrapper for modules, a config specification for paths, shims, and whatever.

Sheesh. What’s all this stuff I have to learn? Why all the complexity? Why is there a whole new framework I have to learn in order to modularize my web page?

RequireJS does have a way of handling CommonJS modules but it requires manual conversion of all the modules. That’s not going to fly.

Another solution is Browserify which reads all the JavaScript files, interprets the require()s and creates a single bundle to include in the web page. This does solve part of the async loading problem but introduces a step that would be different between developement and production.

The main difference between NodeJS’s require() and RequireJS is that the former uses JavaScript language features to do its thing while packages like RequireJS introduce a new level of abstraction and complexity. Do I really need to learn a new framework in order to get asynchronous loading? It seems so unnecessary.

Other people have wanted a simple require() (my unhappiness is shared) and they have created some alternatives. Some discussion in Relation Between CommonJS and RequireJS (http://stackoverflow.com/questions/16521471/relation-between-commonjs-amd-and-requirejs), Some simple solutions are given in Node Style Require for Browser JavaScript.

I am giving NodularJS and Smoothie a try.

Others:

And don’t get me started on the crush of JavaScript package managers (Npm, Bower, Grunt, Gulp, Broccoli, Mimosa, webpack, rollup and it goes on and on). A nice summary of choices.