Hm, I have some doubts whether including JS by PHP generated <script src="…"> links is future proof. New JavaScript syntax has been rolled out with a considerable speed in the last view years, and any script using only a single new syntactic construct would miserably fail on old browsers. Therefore, it doesn't make sense to even deliver such scripts in the first place; instead the script loading should be triggered by JS, guarded by some
CTM[1], and the initialization would be a few lines at most, so it could be written into the document (i.e. the generated HTML) directly. The latter could still use something like ::addScript(), though, in which case it might make sense to offer a variant (or even to restrict to this variant) that does the details (namely to create, configure and insert the desired <script> element) behind the scenes. An alternative might be a general loader (or even a depency checker) written in JS, but even that would still require to somehow get started, i.e. to emit a minimal <script> element. However, all such <script> elements could be joined into a single one.
Another option would be not to use newer JS syntax, but rather to stick with what ES 3 offers. While some may consider this a viable option nowadays, it certainly isn't forever.
[1] CTM (whichever variant) is certainly no proper feature detection, but rather mostly
unrelated existence inference. However, at least nowadays it appears to be a rather pragmatic solution.