quicklink
quicklink copied to clipboard
Can you manipulate Preload for setting priority?
I haven't experimented, but I think you could manipulate priority by using e.g. <link rel="preload" as="image | script | style | ..." href="theLinkToPreload">?
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.
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.
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.
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).