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

# up.fragment.etag(element)

Returns the [ETag](https://en.wikipedia.org/wiki/HTTP_ETag) of the content in the given element.

The returned ETag corresponds to the [`ETag` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) in the response that rendered the fragment. Alternatively the [`[up-etag]`](https://unpoly.com/api/up-etag.md) attribute of the element or an ancestor is used.

If no ancestor fragment with an [`[up-etag]`](https://unpoly.com/api/up-etag.md) attribute exists, `undefined` is returned.

When the fragment is reloaded, its ETag is sent as an [`If-None-Match`](https://unpoly.com/api/If-None-Match.md) request header. The server may check the header and decide to [skip rendering](https://unpoly.com/learn/conditional-requests.md).

<nav aria-label="Guides">

- [Learn: Conditional requests](https://unpoly.com/learn/conditional-requests.md)

</nav>

---

## Parameters {#parameters}

### element {#element}

(required)

Type: [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)

---

## Return value {#return-value}

The fragment's ETag.

Returns `undefined` if the fragment was rendered without an ETag.

Type: string | undefined

