Edit this page

up.link up.link.preload(link, [options])
JavaScript function

Preloads a GET link.

When the link is clicked later, the response will already be cached, making the interaction feel instant.

You may use this function to programmatically populate the cache with pages the user is likely to click or requires accessible while offline.

Preloading links


General

[options]
optional

Render options to apply when preloading this link.

Most options for up.follow() can be used, but no elements will be changed while preloading.

Request

[options.headers={}]
optional

An object with additional request headers.

Unpoly will by default send a number of custom request headers. E.g. the X-Up-Target header includes the targeted CSS selector. See up.protocol for details.

[options.abortable=false]
optional

Whether the request may be aborted by other requests targeting the same fragments or layer.

See Aborting rules in layers.

boolean
[options.background=true]
optional

Whether this request will load in the background.

Background requests deprioritized over foreground requests. Background requests also won't emit up:network:late events and won't trigger the progress bar.

boolean

Return value

A promise that will be fulfilled when the request was loaded and cached.

When the link cannot be preloaded, the promise rejects with an error.