Giter Club home page Giter Club logo

flying-pages's Introduction

Flying Pages

Flying Pages prefetch pages before the user click on links, making them load instantly

Quick Links

Buy Me A Coffee

Usage

Quickstart:

<script src="flying-pages.min.js"></script>

With options:

<script>
  window.FPConfig = {
    delay: 0,
    ignoreKeywords: [],
    maxRPS: 3,
    hoverDelay: 50,
  };
</script>
<script defer src="flying-pages.min.js"></script>
  • delay: Start prefetching after a delay (in seconds). Will be started when the browser becomes idle, using requestIdleCallback. Default to 0.
  • ignoreKeywords: An array of keywords to ignore from prefetching. Example ['/logout','/cart','about.html','sample.png','#'].
  • maxRPS: Maximum requests per second the queue should process. Set to 0 to process all requests immediately (without queue). Default to 3.
  • hoverDelay: Delay in prefetching links on mouse hover (in milliseconds). Default 50.

How it Works?

Flying Pages injects a tiny JavaScript code (1KB gzipped), waits until the browser becomes idle. Then it detects pages in the viewport and on mouse hover and prefetch them.

Flying Pages is intelligent to make sure prefetching doesn't crash your server or make it slow.

  • Prefetch pages in the viewport - Detect links within the viewport (current viewing area) using 'Intersection Observer' and tells the browser to prefetch them using 'prefetch', switch to xhr if not available (similar to Quicklink).

  • Prefetch pages on mouse hover - On hovering links, if it's not prefetched yet using above 'viewport', then Flying Pages will prefetch them instantly (similar to Instant page).

  • Limits the number of prefetch per second - If your page has too many links, prefetching all at the same time will cause the server to crash or slow down the website to visitors. Flying Pages limits the number of prefetchs per second (3 req/sec by default) using an in-built queue. For example, if you've 10 links in the viewport, prefetching all these are span into 4 seconds.

  • Stops prefetching if the server is busy - In case the server starts to respond slowly or return errors, prefetching will be stopped to reduce the server load.

  • Understands user's connection and preferences - Checks if the user is on a slow connection like 2G or has enabled data-saver. Flying Pages won't prefetch anything in this case.

flying-pages's People

Contributors

dependabot[bot] avatar fedleiv avatar gijo-varghese avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flying-pages's Issues

Does not fallback to XHR?

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.

Flying SCRIPTS ??

Hello, am sorry but i cant find repository for Flying Scripts,

so can i try here? pls

Does it work for me? When the google speed test for "www-embed-player.js" reports the same "ms" as before the test.

The screenshot of my "settings in administration" is the second one, at the end.

My next question is whether the plugin can deal with the google message: "Some third-party resources can be lazy loaded with a facade"

google speed test:

sdfsf

my settings in admin:

dfdf

Load All Viewable And Non-Viewable Internal Link

Dear Flying Pages

I have 15 links (5 viewable + 10 non-viewable) on screen in every pages. I changed from default 3 to 20 but the result is only load viewable links. So visitors have to scroll down first to make all non-viewable loaded.

I need to load all (viewable + non-viewable) links without visitor scrolling down first. How to configure it?

Regards

Add a license.md file

Hi! Currently, the license is only specified in the package.json file so it isn't displayed on the GitHub sidebar; a license.md file could be added to more clearly state the chosen license for the project.

Warning: get_headers() error?

Hello
Warning: get_headers(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/fz43556/somedomain/www/wp-content/plugins/flying-pages/settings/compatibility.php on line 6

Warning: get_headers(): This function may only be used against URLs in /home/fz43556/somedomain/www/wp-content/plugins/flying-pages/settings/compatibility.php on line 6

What does it means? cant see plugin working..
Thank you

Anchors - duplicated prefetches

Hello,

I inlined your script to make my website faster, but i noticed that it is downloading the page im already in multiple times.
I figured thats because i have internal links (footnotes, headers).

Maybe it would be smart to keep track of urls (without #) and prevent script from firing off duplicated requests.

This is how it looks like:
image

Other than that great job, it works very nice and is easy to use.

Preconnect or DNS Prefetch Cross-Origin Domains

It isn't always possible to prefetch cross-origin resources, however, some optimizations can still be made for external links by requesting the browser prefetch the dns records or preconnect to the host. Twitter has enabled such a service while hovering over tweets to external urls.
fcc gov-twitter-preconnect

I would like to propose adding a feature to appending dns-prefetch or preconnect html tags when a user hovers or begins to click off-domain url.

<link rel="preconnect" href="https://example.com">
<link rel="dns-prefetch" href="https://example.com">

Easy Digital Downloads Checkout Issues

Hello,

Installing the plugin with Easy Digital Downloads creat issues with the cart page. The end result is that the cart shows as empty and no payment can be procced.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.