Experimenting with preload/preconnect - is it possible?

Hi Tim!

I watched your video on experimenting with service workers and WebPageTest. Wonderful stuff!

It made me wonder if is it possible to experiment with preload/preconnect using Inject Script. Is it?

I found these two amazing snippets, but they didn’t seem to work for me:

Do you know of a resource that can help?

Thanks!

Do you have a test result URL with a preconnect or preload that isn’t working that you could share? If it is for a font, make sure you are using “crossorigin” but depending on the resource type, if it is already in the HTML and parseable, the browser may already be discovering it as fast as possible.

Hi Patrick,

Thanks so much for chipping in.

Here is the original test: https://www.webpagetest.org/result/210923_AiDcDT_fe5b1b12fc248488ed783a6cc467b061/

Here is the test with preconnect (script from Andie Davis’ article): https://www.webpagetest.org/result/210926_BiDcGG_b04abe0235b5cb1111d8fe536682adc0/

And here is the script with preload (script from Hariom Balhara’s article): https://www.webpagetest.org/result/210926_AiDc83_c6fd8f3edbbf12d8368312146eb9adb0/

It’s for an image in this case. Maybe I’m doing something wrong, obviously.

Greatly appreciate your input.

Thank you!