Learning the AMD specification
Before ESM was established, people tried to make modules work in the browser, too. One of the earliest attempts was a small library called RequireJS. RequireJS is a module loader that works in the browser as well as in Node.js. Initially, the essential idea was that a script reference to RequireJS would be embedded in the <head>
of a document. The script would then load and run a defined root module, which would process even more modules.
An example website using RequireJS is as follows:
<!DOCTYPE html>
<html>
<head>
<title>My Sample Project</title>
<!--
data-main attribute tells RequireJS to load
./main.js after ./require.js has been loaded
-->
<script data-main="./main" src="./require.js"></script...