I've used HTML dependencies before to abstract-away this issue, but here I'd like to use singleton() directly and obviously I'm doing something wrong :-/
Can anyone point me to some working examples of singleton()? (I started to read the unit tests within {htmltools} directly, but I figured to ask the community before heading down that rabbit-hole :-).)
After some more experimenting, it seems the 'unique' key is simply the argument to singleton() (and not any DOM context while actually assembling the HTML of that argument), as this results in only a single script tag (in this case, in the <body>, not the <head>, as the former appears first in the R-handling (though second in the rendered HTML)):