PhantomJS: injecting a script before any other scripts run
问题 Using PhantomJS, I'd like to inject some JS as if there was an extra <script> tag before any other <script> tags. This is because the scripts on the page use some functions that PhantomJS does not have, namely Function.prototype.bind and window.webkitRequestAnimationFrame . I have a JS file with custom implementations of the two and I'd like PhantomJS to use them when running the scripts on the page. The difficulty is that if I do page.injectJs before page.open, the script is injected into an