Closed greg-does-weather closed 1 month ago
This issue appears to be a draft or in-progress ADR. When it is completed and accepted, add the ADR: Accepted
label and close the issue. This will start a process to create the ADR document and add it to the repo automatically. If you close the issue before adding the label, simply re-open and re-close it.
This LGTM but will defer to @eric-gade for final approval
Context
The amount of custom frontend Javascript has continued to grow. We chose to keep our code components isolated to the degree practicable and use Drupal's native libraries functionality to import the components into the pages that needed them. The result has been that we only load the code necessary to render the page correctly. However, it has turned out that the total list of libraries necessary for a given page is constant, regardless of the content, with the sole exception that the point location page sometimes does not need the Leaflet and alert mapping components.
As a result, loading a single page also requires making multiple requests to fetch the necessary scripts for that page.
Decision
Instead of serving multiple scripts, we will instead bundle them into page-based modules and serve only a single custom Javascript file per page. We will not create a single "app" bundle. We will build the bundles as part of our CI/CD process rather than commit the built files to the repo. Our tests will use the bundles rather than the individual files. Our bundles will be accompanied by sourcemaps.
Consequences
Positive
Neutral
Negative
main
. The deployed code will be bundled and minified.