Back in the 2010s, AMD was the best way to load JavaScript in web pages. There were no modules yet in browser JavaScript. Bundling, was nascent. The alternative was global-loading JavaScript via the script tag.
An anecdote may help understand the situation. I began a new web dev job in 2014, focusing on the front end. The codebases I was faced with had no package management, and used global-loading. I was tasked with adding functionality to one of those codebases.
The first thing I did was refactor the codebase to allow my new code to be plugged in with minimal impact on the existing functionality. (I’ll write about the evolution of that plugin system at a later date.) To even begin coding I needed to know the specific versions of libraries involved, and a sane way of adding new libraries to support the new functionality. The codebase had absolutely no support for this, other than reading the header comments for a library’s source.
So I set about to adding bower to support dependency management. This involved inspecting each library and library version and finding the bower package for it. (Again, I’ll write more about this later.)
Once I had handle on bower packaging, I focused on library loading and dependency expression in the code itself. As I said above, the only viable option was AMD. I chose the requirejs implementation after a review of available options. It was mature, supported, worked very well, and was backwards compatible to IE (of course we needed to support IE in those days … and we were a federally funded research support organization so need to support as many users as possible.)
I found that this combination was quite potent and stable. There were quirks and workarounds around the edges, like misbehaving libraries, or libraries that were never distributed via bower.
Eventually this system was updated to support more modern practices, and is now defunct. However, to this day I have a fondness for how that ecosystem works, especially for web apps which require lightweight JavaScript support.
So I am now reviving this web app structure (other than bower, which is now deprecated and unreliable.) I’ve created (and this site is using) a new AMD implementation, amd.js. It is driven by simplicity. It supports only commonly used browsers (no IE!). It will support the use cases I found to be optimal.
I’ll document this effort through a series of articles, and of course the codebase itself.