gijo-varghese / flying-pages

Load inner pages instantly, intelligently

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does not fallback to XHR?

moory-se opened this issue · comments

Hi,

Reading the code, I fail to find where it actually "fallbacks to XHR".

  // Prefetch the given url using native 'prefetch'. Fallback to 'xhr' if not supported
  const prefetch = (url) =>
    new Promise((resolve, reject) => {
      const link = document.createElement(`link`);
      link.rel = `prefetch`;
      link.href = url;
      link.onload = resolve;
      link.onerror = reject;
      document.head.appendChild(link);
    });

It does not seem to be a fallback mechanism built in here.

This code is, if I read it correctly, in fact not even running since we stop execution on line 21 if prefetch is not supported:

  // Don't start prefetching if user is on a slow connection or not supported
  if (isSlowConnection || !isSupported) return;

Am I missing something? If not, I'll happily make a PR that actually implements XHR. I guess this be very inspired by how Quicklink does it.