Allow apps to add/modify config js output via hook.

Backport of #7344.