Skip to content

orestbida/link-prefetcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

link-prefetcher

GitHub GitHub file size in bytes Build

A tiny link prefetcher (yet another one in the sea of prefetching tools). Uses fetch/xhr to prefetch links rather than the link tag.

prefetchHover()

Start prefetching as soon as possible. Abort if the cursor leaves the anchor tag before the prefetch process is done.

prefetchVisible()

Immediately prefetch all visible links (⚠️ use with caution, can eat up a lot of bandwidth).

Installation

npm i @orestbida/link-prefetcher

Usage

import { prefetchHover } from 'link-prefetcher';

prefetchHover();

or

<script defer src="dist/index.umd.js"></script>
<script>
    window.addEventListener('load', () => {
        LinkPrefetcher.prefetchHover()
    });
</script>

License

Distributed under the MIT License. See LICENSE for more information.