quicklink icon indicating copy to clipboard operation
quicklink copied to clipboard

Can you manipulate Preload for setting priority?

Open kurtextrem opened this issue 6 years ago • 4 comments

I haven't experimented, but I think you could manipulate priority by using e.g. <link rel="preload" as="image | script | style | ..." href="theLinkToPreload">?

kurtextrem avatar Dec 14 '18 18:12 kurtextrem

One of the ideas in our experiments backlog is to try rel=preload for high priority fetches in prefetch.mjs.

I hadn't added it initially because you do need to specify a valid as type when using it. We could try inferring this from say, the URLs file extension but think this would need to be carefully implemented and could be brittle.

I can see cases where we try to preload a HTML document (don't believe this is supported) [meaning we would have to fall back to fetch() or XHR] or a valid "as" can't be determined from the URL alone.

I'm going to keep this open to see if preload support is something folks really want.

addyosmani avatar Dec 15 '18 20:12 addyosmani

Spec has document for preloading HTML, but according to MDN it is meant for future iframes. Not sure how this affects the loading though. It even has fetch. Might be worth investigating how adding preload as="fetch" + regular fetch directly afterwards affects the speed & priority.

kurtextrem avatar Dec 16 '18 09:12 kurtextrem

I'm trying this right now to preload HTML w/quicklinks and I think it's great. It works correctly in Chrome, no network requests are sent for HTML with preloaded as=fetch.

nateberkopec avatar Apr 17 '20 22:04 nateberkopec

Actually, whoops, I should clarify. I'm not actually navigating in my app. I'm using PJAX, which means HTML is fetched via XHR, so according to spec, my approach should work.

Not saying that preload as=fetch -> regular navigation works, b/c it doesn't (and shouldn't).

nateberkopec avatar Apr 17 '20 22:04 nateberkopec