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

# [up-follow]

[Follows](https://unpoly.com/api/up.follow.md) this link with JavaScript and updates a fragment with the server response.

Following a link is considered [navigation](https://unpoly.com/learn/navigation-defaults.md) by default.

<nav aria-label="Guides">

- [Learn: Following links](https://unpoly.com/learn/following-links.md)

</nav>

<nav aria-label="Contents">

#### Contents

- [Example](#example)
- [Following all links automatically](#following-all-links-automatically)
- [Unfollowable links](#unfollowable-links)
- [Preventing Unpoly from following links](#preventing-unpoly-from-following-links)
- [Making non-interactive elements act as hyperlinks](#making-non-interactive-elements-act-as-hyperlinks)
- [Advanced fragment changes](#advanced-fragment-changes)
- [Short notation](#short-notation)
- [Modifying attributes](#attributes)

</nav>

## Example {#example}

This link will update the `<div class="content">` fragment with the same element fetched from `/posts/5`:

```html
<a href="/posts/5" up-follow up-target=".content">Read post</a>
```

If no `[up-target]` attribute is set, the [main fragment](https://unpoly.com/api/up-main.md) is updated.

## Following all links automatically {#following-all-links-automatically}

You can configure Unpoly to follow _all_ links on a page without requiring an `[up-follow]` attribute.

See [Handling all links](https://unpoly.com/learn/handling-all-links.md).

## Unfollowable links {#unfollowable-links}

Even with an `[up-follow]` attribute, some links cannot be handled by Unpoly:

- Links with an `[up-follow=false]` attribute. Also see [boolean attributes](https://unpoly.com/learn/attributes-and-options.md#boolean-attributes).
- Links with a [`[download]`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download) attribute.
- Links with a [`[target]`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-target) attribute (to target an iframe or open new browser tab).
- Links with a `javascript:`, `mailto:` or `tel:` scheme.
- Links with a cross-origin `[href]`.
- Links with an `[href]` that only contains a `#hash` (like `#` or `#section`) and don't also have local HTML in an `[up-document]`, `[up-fragment]`, or `[up-content]` attribute.
- Any additional exceptions configured in [`up.link.config.noFollowSelectors`](https://unpoly.com/api/up.link.config.md#config.noFollowSelectors).

Clicking such links will fall back to default browser behavior.

## Preventing Unpoly from following links {#preventing-unpoly-from-following-links}

You can tell Unpoly to ignore clicks on an `[up-follow]` link, causing the link to be non-interactive. Use one of the following methods:

- Prevent the [`up:link:follow`](https://unpoly.com/api/up:link:follow.md) event on the link element
- Prevent the [`up:click`](https://unpoly.com/api/up:click.md) event on the link element

To force a [full page load](https://unpoly.com/api/up.network.loadPage.md) when a followable link is clicked:

- Set an [`[up-follow=false]`](https://unpoly.com/learn/attributes-and-options.md#boolean-attributes) attribute on the link element
- Prevent the [`up:link:follow`](https://unpoly.com/api/up:link:follow.md) event, then call [`up.network.loadPage(event.renderOptions)`](https://unpoly.com/api/up.network.loadPage.md)

## Making non-interactive elements act as hyperlinks {#making-non-interactive-elements-act-as-hyperlinks}

You can set an `[up-follow]` attribute on any non-interactive element to make it behave like a hyperlink:

```html
<span up-follow up-href="/details">Read more</span>
```

See [Acting like a hyperlink](https://unpoly.com/learn/faux-interactive-elements.md#acting-like-a-hyperlink) for details.

## Advanced fragment changes {#advanced-fragment-changes}

Links can update multiple fragments or append content to an existing element.

See [Fragment placement](https://unpoly.com/learn/targeting-fragments.md) for details.

## Short notation {#short-notation}

You may omit the `[up-follow]` attribute if the link has one of the following attributes:

- `[up-target]`
- `[up-layer]`
- [`[up-transition]`](https://unpoly.com/api/up-transition.md)
- `[up-content]`
- `[up-fragment]`
- `[up-document]`

Such a link will still be followed through Unpoly.

---

## Modifying attributes {#attributes}

### Targeting {#attributes-targeting}

#### [up-target=':main'] {#up-target}

(optional)

The [target selector](https://unpoly.com/learn/targeting-fragments.md) to update after a successful response.

If omitted, a [main target](https://unpoly.com/api/up-main.md) will be rendered.

#### [up-fail-target=':main'] {#up-fail-target}

(optional)

The [target selector](https://unpoly.com/learn/targeting-fragments.md) to update when the server responds with an error code.

See [Rendering error responses differently](https://unpoly.com/learn/error-responses.md#fail-options) for details.

If omitted, an error response will _not_ update the [`[up-target]`](#up-target), but update the [main fragment](https://unpoly.com/api/up-main.md) instead.

#### [up-fallback='true'] {#up-fallback}

(optional)

Specifies behavior if the [target selector](https://unpoly.com/api/up.render.md#options.target) is missing from the current page or the server response.

If set to a CSS selector, Unpoly will attempt to replace that selector instead.

If set to `true`, Unpoly will attempt to replace a [main target](https://unpoly.com/api/up-main.md) instead.

If set to `false`, Unpoly will immediately reject the render promise.

#### [up-match='region'] {#up-match}

(optional)

Controls which fragment to update when the [`[up-target]`](#up-target) selector yields multiple results.

When set to `'region'`, Unpoly will prefer to update fragments in the [region](https://unpoly.com/learn/targeting-fragments.md#ambiguous-selectors) of the [origin element](https://unpoly.com/api/up.render.md#options.origin).

If set to `'first'`, Unpoly will always update the first matching fragment.

Defaults to [`up.fragment.config.match`](https://unpoly.com/api/up.fragment.config.md#config.match), which defaults to `'region'`.

#### [up-use-hungry='true'] (Experimental) {#up-use-hungry}

(optional)

Whether [`[up-hungry]`](https://unpoly.com/api/up-hungry.md) elements outside the updated fragment will also be updated.

### Navigation {#attributes-navigation}

#### [up-navigate='true'] {#up-navigate}

(optional)

Whether this fragment update is considered [navigation](https://unpoly.com/learn/navigation-defaults.md).

Setting this to `false` will disable most defaults documented below, causing Unpoly to render a fragment without side-effects like updating history or scrolling.

### Request {#attributes-request}

#### [href] {#href}

(optional)

The URL to fetch from the server.

See [loading content from a URL](https://unpoly.com/learn/providing-html.md#url).

To use a different URL when a link is followed through Unpoly (as opposed to a browser's full page load), set an [`[up-href]`](https://unpoly.com/api/up-href.md) attribute.

Instead of making a server request, you may also render an [existing string of HTML](https://unpoly.com/learn/providing-html.md#string).

#### [up-method='get'] {#up-method}

(optional)

The HTTP method to use for the request.

Common values are `get`, `post`, `put`, `patch` and `delete`. The value is case-insensitive.

The HTTP method may also be passed as a `[data-method]` attribute.

By default, methods other than `get` or `post` will be converted into a `post` request, and carry their original method as a configurable [`_method` parameter](https://unpoly.com/api/up.protocol.config.md#config.methodParam).

#### [up-params] {#up-params}

(optional)

A [relaxed JSON](https://unpoly.com/api/relaxed-json.md) object with additional [parameters](https://unpoly.com/api/up.Params.md) that should be sent as the request's [query string](https://en.wikipedia.org/wiki/Query_string) or payload.

When making a `GET` request to a URL with a query string, the given `{ params }` will be added to the query parameters.

#### [up-headers] {#up-headers}

(optional)

A [relaxed JSON](https://unpoly.com/api/relaxed-json.md) 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 [target selector](https://unpoly.com/learn/targeting-fragments.md). See [`up.protocol`](https://unpoly.com/api/up.protocol.md) for details.

#### [up-abort='target'] {#up-abort}

(optional)

Whether to [abort existing requests](https://unpoly.com/learn/aborting-requests.md) before rendering.

#### [up-abortable='true'] {#up-abortable}

(optional)

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

See [aborting requests](https://unpoly.com/learn/aborting-requests.md) for details.

#### [up-background='false'] {#up-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).

#### [up-late-delay] {#up-late-delay}

(optional)

The number of milliseconds after which this request can cause an [`up:network:late`](https://unpoly.com/api/up:network:late.md) event.

Defaults to [`up.network.config.lateDelay`](https://unpoly.com/api/up.network.config.md#config.lateDelay).

#### [up-timeout] {#up-timeout}

(optional)

The number of milliseconds after which this request fails with a timeout.

Defaults to [`up.network.config.timeout`](https://unpoly.com/api/up.network.config.md#config.timeout).

#### [up-fail] {#up-fail}

(optional)

Whether to render [error responses](https://unpoly.com/learn/error-responses.md) differently.

For error responses Unpoly will use attributes prefixed with `up-fail`, e.g. [`[up-fail-target]`](https://unpoly.com/api/up-follow.md#up-fail-target).

By [default](https://unpoly.com/api/up.network.config.md#config.fail) any HTTP status code other than 2xx or [304](https://unpoly.com/learn/conditional-requests.md#rendering-nothing) is considered an error code. Set `[up-fail=false]` to handle _any_ response as successful, even with a 4xx or 5xx status code.

### Local content {#attributes-local-content}

#### [up-content] {#up-content}

(optional)

The new [inner HTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML) for the targeted fragment.

See [Updating an element's inner HTML from a string](https://unpoly.com/learn/providing-html.md#content).

Instead of passing an HTML string you can also [pass a template selector](https://unpoly.com/learn/templates.md), optionally with [variables](https://unpoly.com/learn/placeholders.md#dynamic-templates).

#### [up-fragment] {#up-fragment}

(optional)

A string of HTML comprising _only_ the new fragment's [outer HTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/outerHTML).

With an `[up-fragment]` attribute you can omit the `[up-target]` attribute. The target will be [derived](https://unpoly.com/learn/target-derivation.md) from the root element in the given HTML.

See [Rendering a string that only contains the fragment](https://unpoly.com/learn/providing-html.md#fragment).

Instead of passing an HTML string you can also [pass a template selector](https://unpoly.com/learn/templates.md), optionally with [variables](https://unpoly.com/learn/placeholders.md#dynamic-templates).

#### [up-document] {#up-document}

(optional)

A string of HTML containing the targeted fragment.

See [Extracting an element's outer HTML from a larger HTML string](https://unpoly.com/learn/providing-html.md#document).

Instead of passing an HTML string you can also [pass a template selector](https://unpoly.com/learn/templates.md), optionally with [variables](https://unpoly.com/learn/placeholders.md#dynamic-templates).

### Layer {#attributes-layer}

#### [up-layer='origin, current'] {#up-layer}

(optional)

The [layer](https://unpoly.com/api/up.layer.md) in which to match and render the fragment.

See [layer option](https://unpoly.com/learn/targeting-other-layers.md) for a list of allowed values.

To [open the fragment in a new overlay](https://unpoly.com/learn/opening-overlays.md), pass [`[up-layer=new]`](https://unpoly.com/api/up-layer-new.md). In this case attributes for [`[up-layer=new]`](https://unpoly.com/api/up-layer-new.md) may also be used.

#### [up-fail-layer='origin, current'] {#up-fail-layer}

(optional)

The [layer](https://unpoly.com/api/up.layer.md) in which to render if the server responds with an error code.

See [Rendering error responses differently](https://unpoly.com/learn/error-responses.md#fail-options).

#### [up-peel='dismiss'] {#up-peel}

(optional)

Whether to close overlays obstructing the target layer, when [updating a background layer from an overlay](https://unpoly.com/learn/closing-overlays.md#peeling).

By default, obstructing overlays will be [dismissed](https://unpoly.com/learn/closing-overlays.md#intents).
To [accept](https://unpoly.com/learn/closing-overlays.md#intents) them instead, set `[up-peel="accept"]`.
To not peel, set `[up-peel="false"]`.

### History {#attributes-history}

#### [up-history='auto'] {#up-history}

(optional)

Whether the browser URL, window title and meta tags will be [updated](https://unpoly.com/learn/updating-history.md).

If set to `true`, the history will always be updated, using the title and URL from the server response, or from given `[up-title]` and `[up-location]` attributes.

If set to `auto`, history will be updated if the `[up-target]` matches a selector in [`up.fragment.config.autoHistoryTargets`](https://unpoly.com/api/up.fragment.config.md#config.autoHistoryTargets). By default this contains all [main targets](https://unpoly.com/api/up-main.md).

If set to `false`, the history will remain unchanged.

See [Updating history](https://unpoly.com/learn/updating-history.md).

#### [up-fail-history='auto'] {#up-fail-history}

(optional)

Whether to update history when the server responds with an error code.

See [Rendering error responses differently](https://unpoly.com/learn/error-responses.md#fail-options).

#### [up-title] {#up-title}

(optional)

An explicit document title to set before rendering.

By default the title is extracted from the response's `<title>` tag. To prevent the title from being updated, set `[up-title=false]`.

This attribute is only used when [updating history](#up-history).

#### [up-location] {#up-location}

(optional)

An explicit URL to set before rendering.

By default Unpoly will use the link's `[href]` or the final URL after the server redirected. To prevent the URL from being updated, set `[up-location=false]`.

This attribute is only used when [updating history](#up-history).

#### [up-meta-tags] {#up-meta-tags}

(optional)

Whether to update [meta tags](https://unpoly.com/api/up-meta.md) in the `<head>`.

By default Unpoly will extract meta tags from the response's `<head>`. To prevent meta tags from being updated, set `[up-meta-tags=false]`.

This attribute is only used when [updating history](#up-history).

#### [up-lang] {#up-lang}

(optional)

An explicit language code to set as the [`html[lang]`](https://www.tpgi.com/using-the-html-lang-attribute/) attribute.

By default Unpoly will extract the language from the response and update the `html[lang]` attribute in the current page. To prevent the attribute from being changed, set `[up-lang=false]`.

This attribute is only used when [updating history](#up-history).

### Animation {#attributes-animation}

#### [up-transition] {#up-transition}

(optional)

The name of a [transition](https://unpoly.com/api/up.motion.md) to morph between the old and new fragment.

If you are [prepending or appending content](https://unpoly.com/learn/targeting-fragments.md#appending-or-prepending), use the `[up-animation]` attribute instead.

#### [up-animation] {#up-animation}

(optional)

The name of an [animation](https://unpoly.com/learn/animations.md) to play on the new content when [prepending or appending content](https://unpoly.com/learn/targeting-fragments.md#appending-or-prepending).

If you are replacing content (the default), use the [`[up-transition]`](https://unpoly.com/api/up-transition.md) attribute instead.

#### [up-duration] {#up-duration}

(optional)

The duration of the transition or animation (in milliseconds).

#### [up-easing] {#up-easing}

(optional)

The timing function that accelerates the transition or animation.

See [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/transition-timing-function) for a list of available timing functions.

### Caching {#attributes-caching}

#### [up-cache='auto'] {#up-cache}

(optional)

Whether to read from and write to the [cache](https://unpoly.com/learn/caching.md).

With `[up-cache=true]` Unpoly will try to re-use a cached response before connecting to the network. To prevent display of stale content, cached responses are [reloaded once rendered](#up-revalidate). If no cached response exists, Unpoly will make a request and cache the server response.

With `[up-cache=auto]` Unpoly will use the cache only if [`up.network.config.autoCache`](https://unpoly.com/api/up.network.config.md#config.autoCache) returns `true` for the request. By default this only caches `GET` requests.

With `[up-cache=false]` Unpoly will always make a network request.

#### [up-revalidate='auto'] {#up-revalidate}

(optional)

Whether to [reload the targeted fragment](https://unpoly.com/learn/caching.md#revalidation) after it was rendered from a cached response.

With `[up-revalidate='auto']`, Unpoly will revalidate [expired](https://unpoly.com/learn/caching.md#expiration) responses. This behavior can be configured with [`up.fragment.config.autoRevalidate(response)`](https://unpoly.com/api/up.fragment.config.md#config.autoRevalidate).

With `[up-revalidate='true']`, Unpoly will always revalidate cached content, regardless of its age.

With `[up-revalidate='false']`, Unpoly will never revalidate cached content.

#### [up-revalidate-preview] (Experimental) {#up-revalidate-preview}

(optional)

The name of a [preview](https://unpoly.com/learn/previews.md) that runs while [revalidating cached content](https://unpoly.com/learn/caching.md#revalidation).

#### [up-expire-cache] {#up-expire-cache}

(optional)

Whether existing [cache](https://unpoly.com/learn/caching.md) entries will be [expired](https://unpoly.com/learn/caching.md#expiration) when this request is sent.

By default a non-GET request will expire the entire cache. Set `[up-expire-cache="false"]` to not expire any cache entries. You may also pass a [URL pattern](https://unpoly.com/api/url-patterns.md) to only expire matching requests.

Also see [`up.request({ expireCache })`](https://unpoly.com/api/up.request.md#options.expireCache) and [`up.network.config.expireCache`](https://unpoly.com/api/up.network.config.md#config.expireCache).

#### [up-evict-cache] {#up-evict-cache}

(optional)

Whether existing [cache](https://unpoly.com/learn/caching.md) entries will be [evicted](https://unpoly.com/learn/caching.md#eviction) when this request is sent.

By default no cache entries are evicted. You may also pass a [URL pattern](https://unpoly.com/api/url-patterns.md) to only evict matching requests.

Also see [`up.request({ evictCache })`](https://unpoly.com/api/up.request.md#options.evictCache) and [`up.network.config.evictCache`](https://unpoly.com/api/up.network.config.md#config.evictCache).

### Scrolling {#attributes-scrolling}

#### [up-scroll='auto'] {#up-scroll}

(optional)

How to scroll after the new fragment was rendered.

See [Scrolling](https://unpoly.com/learn/scrolling.md) for a list of allowed values.

#### [up-fail-scroll='auto'] {#up-fail-scroll}

(optional)

How to scroll after the new fragment was rendered from an error response.

See [Rendering error responses differently](https://unpoly.com/learn/error-responses.md#fail-options).

#### [up-scroll-map] {#up-scroll-map}

(optional)

A [relaxed JSON](https://unpoly.com/api/relaxed-json.md) object mapping fragment selectors to a [scrolling option](https://unpoly.com/learn/scrolling.md).

When a scroll map is given, the [`[up-scroll]`](#up-scroll) attribute is ignored.

See [Scrolling multiple viewports](https://unpoly.com/learn/scrolling.md#multiple-viewports) for examples.

#### [up-scroll-behavior='instant'] {#up-scroll-behavior}

(optional)

Whether to [animate the scroll motion](https://unpoly.com/learn/scroll-tuning.md#animating-the-scroll-motion).

#### [up-reveal-snap] {#up-reveal-snap}

(optional)

When to [snap to the top](https://unpoly.com/learn/scroll-tuning.md#snapping-to-the-screen-edge) when scrolling to an element near the top edge of the viewport's scroll buffer.

#### [up-reveal-top] {#up-reveal-top}

(optional)

When to [move a revealed element to the top](https://unpoly.com/learn/scroll-tuning.md#moving-revealed-elements-to-the-top) when scrolling to an element.

#### [up-reveal-padding] {#up-reveal-padding}

(optional)

How much [space to leave to the closest viewport edge](https://unpoly.com/learn/scroll-tuning.md#revealing-with-padding) when scrolling to an element.

#### [up-reveal-max] {#up-reveal-max}

(optional)

How many pixel lines of a [tall element to reveal](https://unpoly.com/learn/scroll-tuning.md#revealing-large-elements) when scrolling to an element.

#### [up-save-scroll='true'] {#up-save-scroll}

(optional)

Whether to [save scroll positions](https://unpoly.com/api/up.viewport.saveScroll.md) before updating the fragment.

Saved scroll positions can later be restored with [`[up-scroll=restore]`](https://unpoly.com/learn/scrolling.md#restore).

### Focus {#attributes-focus}

#### [up-focus='auto'] {#up-focus}

(optional)

What to focus after the new fragment was rendered.

See [Controlling focus](https://unpoly.com/learn/focus.md) for a list of allowed values.

#### [up-fail-focus='auto'] {#up-fail-focus}

(optional)

What to focus after the new fragment was rendered from an error response.

See [Rendering error responses differently](https://unpoly.com/learn/error-responses.md#fail-options).

#### [up-focus-visible='auto'] {#up-focus-visible}

(optional)

Whether the focused element should have a [visible focus ring](https://unpoly.com/learn/focus-visibility.md).

By default focus will be visible if [`up.viewport.config.autoFocusVisible()`](https://unpoly.com/api/up.viewport.config.md#config.autoFocusVisible) returns `true` for the focused element and [current input device](https://unpoly.com/api/up.event.inputDevice.md).

#### [up-save-focus='true'] {#up-save-focus}

(optional)

Whether to [save focus-related state](https://unpoly.com/api/up.viewport.saveFocus.md) before updating the fragment.

Saved focus state can later be restored with [`[up-focus=restore]`](https://unpoly.com/learn/focus.md#restore).

### Loading state {#attributes-loading-state}

#### [up-disable] {#up-disable}

(optional)

[Disables form controls](https://unpoly.com/learn/disabling-forms.md#from-link) while the link is loading.

#### [up-placeholder] (Experimental) {#up-placeholder}

(optional)

A [placeholder](https://unpoly.com/learn/placeholders.md) to show in the targeted fragment while new content is loading.

Existing children of the targeted fragment [will be hidden](https://unpoly.com/learn/placeholders.md#basic-example) during the request. When the request ends for any reason, all changes will be reverted.

You can either [pass a HTML string](https://unpoly.com/learn/placeholders.md#basic-example) or [refer to a template](https://unpoly.com/learn/placeholders.md#from-template), optionally with [variables](https://unpoly.com/learn/placeholders.md#dynamic-templates).

If this link [opens a new overlay](https://unpoly.com/learn/opening-overlays.md), the placeholder will be shown in a temporary overlay with the same [visual style](https://unpoly.com/learn/customizing-overlays.md) and open animation.

#### [up-preview] {#up-preview}

(optional)

The name of a [preview](https://unpoly.com/learn/previews.md) that temporarily changes the page while new content is loading.

The preview changes will be reverted automatically when the request ends for [any reason](https://unpoly.com/learn/previews.md#ending).

#### [up-feedback='true'] {#up-feedback}

(optional)

Whether to set [feedback classes](https://unpoly.com/learn/feedback-classes.md) while loading content.

### Client state {#attributes-client-state}

#### [up-use-data] {#up-use-data}

(optional)

A [relaxed JSON](https://unpoly.com/api/relaxed-json.md) object that [overrides properties](https://unpoly.com/learn/data.md#override) from the new fragment's [data](https://unpoly.com/learn/data.md).

When updating [multiple fragments](https://unpoly.com/learn/targeting-fragments.md#multiple), `{ data }` is only applied to the primary fragment. To apply data to multiple fragments, set [`[up-use-data-map]`](#up-use-data-map).

#### [up-use-data-map] (Experimental) {#up-use-data-map}

(optional)

A [relaxed JSON](https://unpoly.com/api/relaxed-json.md) object mapping selectors to [data objects](https://unpoly.com/learn/data.md).

When a selector matches any element within an updated fragment, the matching element is compiled with the mapped data.

See [Mapping selectors to data](https://unpoly.com/learn/data.md#map).

#### [up-use-keep='true'] (Experimental) {#up-use-keep}

(optional)

Whether [`[up-keep]`](https://unpoly.com/api/up-keep.md) elements will be kept in the updated fragments.

#### [up-context] (Experimental) {#up-context}

(optional)

A [relaxed JSON](https://unpoly.com/api/relaxed-json.md) object that will be merged into the [context](https://unpoly.com/learn/layer-context.md) of the current layer once the fragment is rendered.

### Lifecycle hooks {#attributes-lifecycle-hooks}

#### [up-confirm] {#up-confirm}

(optional)

A message the user needs to confirm before any request or changes are made.

The message will be shown as a [native confirmation dialog](https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm).

If the user does not confirm, no request is sent and no fragments are updated.

The message may also be passed as a `[data-confirm]` attribute, as rendered by Rails helpers like `link_to` or `button_to`.

See [Confirmation dialogs](https://unpoly.com/learn/confirmation-dialogs.md), also for showing a styled dialog instead of the browser's.

#### [up-on-loaded] {#up-on-loaded}

(optional)

A JavaScript snippet that is executed when the server responds with new HTML, but before the HTML is rendered.

The snippet runs in the following scope:

| Expression | Value |
| --- | --- |
| `this` | The link being followed |
| `event` | A preventable [`up:fragment:loaded`](https://unpoly.com/api/up:fragment:loaded.md) event |

The snippet will also run for [error responses](https://unpoly.com/learn/error-responses.md).

#### [up-on-offline] {#up-on-offline}

(optional)

A JavaScript snippet that is executed when the fragment could not be loaded due to a [disconnect or timeout](https://unpoly.com/learn/network-issues.md).

The snippet runs in the following scope:

| Expression | Value |
| --- | --- |
| `this` | The link being followed |
| `event` | An [`up:fragment:offline`](https://unpoly.com/api/up:fragment:offline.md) event |

To try again, call `event.retry()`.

#### [up-on-rendered] {#up-on-rendered}

(optional)

A JavaScript snippet that is executed when Unpoly has updated fragments.

The snippet runs in the following scope:

| Expression | Value |
| --- | --- |
| `this` | The link being followed |
| `result` | The [`up.RenderResult`](https://unpoly.com/api/up.RenderResult.md) for the respective render pass |

The snippet will be called zero, one or two times:

- When the server rendered an [empty response](https://unpoly.com/learn/conditional-requests.md#rendering-nothing), no fragments are updated. `[up-on-rendered]` is not called.
- When the server rendered a matching fragment, it will be updated on the page. `[up-on-rendered]` is called with the [result](https://unpoly.com/api/up.RenderResult.md).
- When [revalidation](https://unpoly.com/learn/caching.md#revalidation) renders a second time, `[up-on-rendered]` is called again with the final result.

Also see [Running code after rendering](https://unpoly.com/learn/render-lifecycle.md#running-code-after-rendering).

#### [up-on-finished] {#up-on-finished}

(optional)

A JavaScript snippet that is executed when no further DOM changes will be caused by this render pass.

The following state is considered "finished":

- [Animations](https://unpoly.com/api/up.motion.md) have concluded and [transitioned](https://unpoly.com/api/up-transition.md) elements have been removed from the DOM tree.
- [Async compilers](https://unpoly.com/api/up.compiler.md#async) have settled.
- [Cached content](https://unpoly.com/learn/caching.md) has been [revalidated with the server](https://unpoly.com/learn/caching.md#revalidation).
  If the server has responded with fresher content, that content has also been rendered.

The snippet runs in the following scope:

| Expression | Value |
| --- | --- |
| `this` | The link being followed |
| `result` | The [`up.RenderResult`](https://unpoly.com/api/up.RenderResult.md) for the last render pass that updated a fragment |

If [revalidation](https://unpoly.com/learn/caching.md#revalidation) re-rendered the fragment, `result` describes updates from the second render pass. If no revalidation was performed, or if revalidation yielded an [empty response](https://unpoly.com/learn/caching.md#when-nothing-changed), it is the result from the initial render pass.

To run a snippet after an [error response](https://unpoly.com/learn/error-responses.md) has finished rendering, set an `[up-on-fail-finished]` attribute instead.

Also see [Awaiting post-processing](https://unpoly.com/learn/render-lifecycle.md#postprocessing).

#### [up-on-error] {#up-on-error}

(optional)

A JavaScript snippet that is run when any error is thrown during the rendering process.

| Expression | Value |
| --- | --- |
| `this` | The link being followed |
| `error` | An [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object |

The callback is also called when the render pass fails due to [network issues](https://unpoly.com/learn/network-issues.md) or [aborts](https://unpoly.com/learn/aborting-requests.md).

Also see [Handling errors](https://unpoly.com/learn/render-lifecycle.md#handling-errors).

