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

# [up-source]

When Unpoly inserts a fragment, the `[up-source]` attribute is automatically set to the URL from which the fragment's HTML was loaded.

When an element is [reloaded](https://unpoly.com/api/up.reload.md) or [polled](https://unpoly.com/api/up-poll.md), Unpoly will request the URL from the closest `[up-source]` attribute.

The `[up-source]` attribute is only set for `GET` requests.

<nav aria-label="Guides">

- [Learn: Polling](https://unpoly.com/learn/polling.md#source)

</nav>

<nav aria-label="Contents">

#### Contents

- [Using an explicit source URL](#using-an-explicit-source-url)
- [Accessing the source URL from JavaScript](#accessing-the-source-url-from-javascript)
- [Modifying attributes](#attributes)

</nav>

## Using an explicit source URL {#using-an-explicit-source-url}

To indicate a different source URL for a fragment (and its descendants), manually set `[up-source]` attribute:

```html
<div class="unread-count" up-poll up-source="/unread-count">
  2 new messages
</div>
```

When such an `[up-source]` attribute is explicitly set in the HTML, Unpoly will not overwrite it on insertion.

## Accessing the source URL from JavaScript {#accessing-the-source-url-from-javascript}

To retrieve the source URL from JavaScript, use [`up.fragment.source()`](https://unpoly.com/api/up.fragment.source.md).

---

## Modifying attributes {#attributes}

### up-source {#up-source}

(required)

The URL from which this element and its descendants were initially requested.

Type: string

