---
name: "up.link.preload"
area: "API"
kind: "JavaScript function"
parent: "up.link module"
url: "https://unpoly.com/api/up.link.preload"
---
<nav aria-label="Unpoly docs">[All docs](https://unpoly.com/index.md) · [up.link module](https://unpoly.com/api/up.link.md)</nav>

# up.link.preload(link, [options])

[Preloads](https://unpoly.com/learn/preloading.md) a `GET` link.

When the link is clicked later, the response will already be [cached](https://unpoly.com/learn/caching.md), making the interaction feel instant.

You may use this function to [programmatically populate the cache](https://unpoly.com/learn/preloading.md#scripted) with pages the user is likely to click or that should be [accessible while offline](https://unpoly.com/learn/network-issues.md#offline-cache).

<nav aria-label="Guides">

- [Learn: Preloading links](https://unpoly.com/learn/preloading.md)

</nav>

---

## Parameters {#parameters}

### General {#parameters-general}

#### link {#link}

(required)

The element or selector whose destination should be preloaded.

Type: string | [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) | [jQuery](https://learn.jquery.com/using-jquery-core/jquery-object/)

#### [options] {#options}

(optional)

[Render options](https://unpoly.com/api/up.render.md#parameters) to apply when preloading this link.

Most [options for `up.follow()`](https://unpoly.com/api/up.follow.md#parameters) can be used, but no elements will be changed while preloading.

Type: [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects)

### Request {#parameters-request}

#### [options.url] {#options.url}

(optional)

The URL to preload.

Defaults to the link's `[href]` attribute.

Type: string

#### [options.headers={}] {#options.headers}

(optional)

An object with additional request headers.

Unpoly will by default send a number of custom request headers. For example, the [`X-Up-Target`](https://unpoly.com/api/X-Up-Target.md) header includes the [targeted](https://unpoly.com/learn/targeting-fragments.md) CSS selector. See [`up.protocol`](https://unpoly.com/api/up.protocol.md) for details.

Type: [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects)

#### [options.abortable=false] {#options.abortable}

(optional)

Whether the request may be aborted by other requests [targeting](https://unpoly.com/learn/targeting-fragments.md) the same fragments or layer.

See [Aborting rules in layers](https://unpoly.com/learn/aborting-requests.md#layers).

Type: boolean

#### [options.background=true] {#options.background}

(optional)

Whether this request will load in the background.

Background requests are deprioritized and won't show the [progress bar](https://unpoly.com/learn/progress-bar.md). See [Background requests](https://unpoly.com/learn/background-requests.md).

Type: boolean

---

## Return value {#return-value}

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

When [caching is disabled](https://unpoly.com/learn/caching.md#disabling-globally), no request is made and the promise fulfills right away.

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

Type: [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises)

