@putiaweb-org/hyperinstant
v2.0.0
Published
HyperInstant: instant-like navigation with hover + idle link crawl prefetch for same-origin links.
Maintainers
Readme
HyperInstant (v2)
HyperInstant is a tiny, dependency-free library inspired by Instant Page.
It speeds up navigation by prefetching internal pages using:
- Hover prefetch (Instant Page style)
- Idle Crawl Prefetch: after the current page is fully loaded, HyperInstant scans same-origin links (menu, buttons, etc.) and prefetches the best candidates one by one, respecting budgets and network safety.
Install
npm i hyperinstantUsage
Basic
import { init } from 'hyperinstant';
init();With options
import { init } from 'hyperinstant';
init({
maxLinksPerPage: 6,
maxConcurrent: 1,
enableHover: true,
enableIdleCrawl: true,
method: 'link-prefetch', // or 'fetch'
ignoreSelector: '[data-hyperinstant="ignore"], .no-prefetch',
onPrefetch: (url, method) => console.log('prefetch', method, url)
});Opt-out (per link)
<a href="/checkout" data-hyperinstant="ignore">Checkout</a>How it decides what to prefetch
During Idle Crawl Prefetch, HyperInstant scores internal links:
- Links in the viewport get highest priority
- Links inside header/nav get a boost
- Links that look like CTA buttons get a boost
- Links with
data-hyperinstant-priority="<number>"get extra priority
Then it picks up to maxLinksPerPage links and prefetches them progressively during idle time.
Safety rules
- Respects
Save-Data - Avoids slow connections via
navigator.connection.effectiveType - Stops/aborts when the tab is hidden
- Excludes common action URLs like
?add-to-cart=,/cart,/checkout,/my-account,/wp-admin, etc.
License
MIT
