MyBB Internal: One or more warnings occured. Please contact your administrator for assistance.
WebPagetest Forums - Trying to inject an external prefetch library into a scripted test

WebPagetest Forums

Full Version: Trying to inject an external prefetch library into a scripted test
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi Pat, I am trying to inject an external prefetch library into a scripted test

Here is the script I wish to inject
Code:
var js = document.createElement("script");

js.type = "text/javascript";
js.src = "https://cdnjs.cloudflare.com/ajax/libs/quicklink/2.0.0-alpha/quicklink.umd.js";

js.onload = function() {
    quicklink.listen();
}
document.body.appendChild(js);

Here are the steps I am looking to setup

Code:
navigate    https://www.foo.com/
sleep    30
navigate    https://www.foo.com/product-2

I see that the steps are being executed properly but the script is not being injected, am I doing something wrong here?

Appreciate your help as always.

Thanks
Akhil
Ok found the answer to this one. If you are using a scripted WPT test then you cannot inject the script via the "inject script" UI. You need to include it as part of your WPT script. So my script now looks like

Code:
navigate https://www.foo.com
execAndWait ar js = document.createElement("script"); js.type = "text/javascript"; js.src = "https://cdnjs.cloudflare.com/ajax/libs/quicklink/2.0.0-alpha/quicklink.umd.js"; js.onload = function() {quicklink.listen();}; document.body.appendChild(js);
sleep 10
navigate https://www.foo.com/products.html
Reference URL's