I've begun to think
that some core support for Javascript management could help to address
some of the issues we've had with managing javascript and dependencies.
(this would most likely work as a core feature rather than a plugin
but I'm undecided on that. And this is hardly a novel idea, I'm sure
[[users/anarcat]] has proposed it somewhere already)

In essence, a central data structure that captures the available
(bundled or referenced) javascript libraries, a function to register
that a page requires a given library, tracking which
libraries are required for a page, then aggregating the requirements
and generating the required `<script>` tags in the `<head>` element,
de-duplicating, preserving any necessary order. This would address
[[bugs/charset attribute on the script element is obsolete]],
[[bugs/duplicate script element for ikiwiki.js]] and
[[bugs/javascript resources placed after html tag]].

A suggestion made in Debian bug [#643338](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=643338)
was to permit users to specify that a given library should be
fetched externally: e.g. from a public CDN URI. Central
management could support that. With some care, it might even
be flexible enough for downstream packagers to de-bundle any
libraries we are shipping and use distribution-packaged copies.

Managing Javascript in a central place would also make it
easier to implement optional build-time minification,
resolving some of [[todo/css and javascript aggregation]].

*— [[Jon]], 2025-09-17*
