Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including instant-load with all npm packages installed. Try it out:

instant-load lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("instant-load/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

instant-load v1.1.1

A JavaScript library to speed up your site


InstantLoadJS is a JavaScript library to speed up your site.

How does it work?

InstantLoad makes your website a one-page website by preloading the next page on your website when hovering a link. When the user clicks the link, the already loaded page replaces the current one with an instant transition. In addition InstantLoadJS offers seamless loading animations to make your website look even more modern.




npm i instant-load


Place the InstantLoad script on the bottom of your webpage, before any other scripts, like this:

<script src="/path/to/instantload.min.js" instantload-blacklist></script>

After adding the instantload.min.js script to your site, you'll need to initialize the library by adding this script after it:

<script instantload-blacklist>InstantLoad.init();</script>

It's important to keep the instantload-blacklist attribute on the scripts above.


InstantLoad offers high level customizations via it's config. You can pass your settings through the InstantLoad.init() function, like this:

InstantLoad.init({reloadPagesOnPopstate: false, loadingStyle:});

Full list of config options

Config property nameTypeDescription
reloadPagesOnPopstatebooleanIf true, on pressing the back/forward button, the target page will be reloaded.
Default: false
loadingStyleInstantLoad.configOptions.loadingStylesCustomize the loading transition.
Possible values:
- bar
- blink
- circle
- invisible
Default: bar

More coming soon...


The InstantLoad object returns some useful values. Let's take a look at them!


This will initialize the InstantLoad script and start speeding up you site


This will return the current config for the library. You can also use it to change the config, after initializing InstantLoad.

InstantLoad.on('eventType', callback)

Used to add your own events to InstantLoad. More belove


This will return the history of your site, after initializing the library.


This stores the options for different config elements


Check if InstantLoad had been initialized

Blacklisting scripts

If you don't want your scripts to get re-inserted and re-initialized, you will find the instantload-blacklist attribute really useful. Add it to your scripts to blacklist it from InstantLoad, like this:

<script src="/path/to/my/script.js" instantload-blacklist></script>

Event Handling

InstantLoad has it's own events, and you can listen to them like this:

InstantLoad.on('change', function(event) {console.log('Page changed', event)});

Event types

Event typeReturn valuesDescription
initeventType: init
trackedElements: All preloadable elements
Occurs after the initialization of InstantLoad
preloadeventType: preloadOccurs before preloading a page, when hovering a link
postloadeventType: postload
success: Whether the request was successful
message: Request message
Occurs after preloading a page, when hovering a link
changeeventType: change
popstateEvent: Whether the change was triggered by the back/forward arrows or not
Occurs after changing the page

Customize the loading styles

You can configure the different loading styles via CSS. You can find the CSS selectors to use above.

#instantload-barThe loading line of the bar styled loading
#instantload-whiteScreenThe blink styled loading's layer
#instantload-circleThe circle styled spinner loading's container
#instantload-circle-spinnerThe circle styled loading's spinner

Why did I make this library?

I was working on a project of mine, and I wanted to use the well-known library, but I realized, that while it is great and very much useful, it lacks some customizations I'd like to use and it is a bit buggy.

So I sat down and wrote my own version of it.

Hope you like it :) Thank you for the inspiration instantclick


You are more than welcome contributing to the library.

Make sure to do npm install, after cloning the repository to install UglifyJs as a devDependency. Use this command to minify:

uglifyjs instantload.js --output instantload.min.js --mangle --source-map

Please make a pull request if you have implemented something new

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free