MDL-44361 Javascript: Fix js_pending injector Y.io

The previous (slightly whacky) way that we were doing this in previous
versions is no longer supported (and was arguably only supported by being
buggy).

The correct way of doing this is to use a trigger.