# HasFetchpriority

> Provides an immutable API for the fetchpriority attribute.

[API reference](/docs/api/index.md) › [HTML Attribute](/docs/extensions/html-attribute/reference/index.md) › HasFetchpriority

| trait | `UIAwesome\Html\Attribute\HasFetchpriority` |
| --- | --- |
| Source | [`src/HasFetchpriority.php`](https://github.com/ui-awesome/html-attribute/blob/main/src/HasFetchpriority.php#L19) |

Used by 3 types:

- [`UIAwesome\Html\Embedded\Img`](/docs/extensions/html/reference/embedded/img/index.md)
- [`UIAwesome\Html\Metadata\Link`](/docs/extensions/html/reference/metadata/link/index.md)
- [`UIAwesome\Html\Metadata\Script`](/docs/extensions/html/reference/metadata/script/index.md)

Provides an immutable API for the `fetchpriority` attribute.

See also: <https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/fetchpriority>.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`fetchpriority()`](#method-fetchpriority) | Sets the `fetchpriority` attribute. | `HasFetchpriority` |

## Method details

### fetchpriority() <span id="method-fetchpriority"></span>

```php
public function fetchpriority(string|UnitEnum|null $value): static
```

Sets the `fetchpriority` attribute.

Hints the browser about the fetch priority for the resource.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php)`\|null` | Fetch priority token, or `null` to remove the attribute. |

**Returns**

`static`: New instance with the updated `fetchpriority` attribute. [`Fetchpriority`](/docs/extensions/html-attribute/reference/values/fetchpriority/index.md) for predefined enum values.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): If the value is not valid.