Added a fix for bug #1698, in which injected scripts were executed out of order, in relation to the DOM.