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

# up.util.task(callback)

Schedules a function to the [JavaScript task queue](https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/) (also "macrotask queue").

## Example {#example}

Pass a function argument to schedule it for the next macrotask:

```js
up.util.task(() => console.log('Hello from next task!'))
console.log('Hello from current task!')
```

---

## Parameters {#parameters}

### callback {#callback}

(required)

The function to schedule.

Type: Function()

