gijo-varghese / flying-pages

Load inner pages instantly, intelligently
ISC License
213 stars 20 forks source link

Does not fallback to XHR? #12

Open moory-se opened 2 years ago

moory-se commented 2 years ago

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.

tunetheweb commented 4 days ago

Looks like this was removed in this commit and released in 2.0.8.