Preload Pages Based On User’s Intention – instant.page

Category: Javascript , Loading , Recommended | February 19, 2023
Authorinstantpage
Last UpdateFebruary 19, 2023
LicenseMIT
Tags
Views949 views
Preload Pages Based On User’s Intention – instant.page

instant.page is a small JavaScript library used to boost the page loading speed by preloading target pages when a user intends to click on the link (mouse hover).

It also supports mobile devices that automatically preloads pages when a user starts touching the screen.

Based on the browser link prefetching mechanism.

How to use it:

Just import the instant.page as a module into the document and done.

<script src="//instant.page/1.1.0" type="module" integrity="sha384-EwBObn5QAxP8f09iemwAJljc+sU+eUXeL9vSBw1eNmVarwhKk2F9vBEpaN9rsrtp"></script>

Preload all the links within the document.

<body data-instant-allow-query-string>
  ...
</body>

Preload specific pages within the document.

<a href="articles?page=3" data-instant>
  Page 3
</a>

Prevent specific pages from preloading.

<a href="articles?page=4" data-no-instant>
  Page 4
</a>

Changelog:

01/17/2025

  • update browser support check and its comment

02/19/2023

  • Refactor: Group top-level variable declarations

Alternatives:

  • SmartPrefetch: Modern Link Prefetching with Hover Detection & Fallback

You Might Be Interested In:


Leave a Reply