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 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 charset attribute on the script element is obsolete, duplicate script element for ikiwiki.js and javascript resources placed after html tag.

A suggestion made in Debian 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 css and javascript aggregation.

Jon, 2025-09-17