GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

TaskPriorityChangeEvent: previousPriority property

Prioritized Task Scheduling API

Prioritized Task Scheduling API

The **`previousPriority`** read-only property of the TaskPriorityChangeEvent interface returns the priority of the corresponding TaskSignal before it was changed and this [`prioritychange`](/docs/Web/API/TaskSignal/prioritychange_event) event was emitted.

This is the value that was set in the [`TaskPriorityChangeEvent` constructor](/docs/Web/API/TaskPriorityChangeEvent/TaskPriorityChangeEvent) argument `options.previous`. <!-- link? -->

The new priority of the task can be read from `event.target.priority`.

## Value

A string, indicating the associated task's priority before it was changed.
This will be one of: [`"user-blocking"`](/docs/Web/API/Prioritized_Task_Scheduling_API#user-blocking), [`"user-visible"`](/docs/Web/API/Prioritized_Task_Scheduling_API#user-visible), [`"background"`](/docs/Web/API/Prioritized_Task_Scheduling_API#background).

## Examples

The code below shows the `previousPriority` being obtained in a handler for a `prioritychange` event.

```js
// Listen for 'prioritychange' events on the controller's signal.
controller.signal.addEventListener("prioritychange", (event) => {
const previousPriority = event.previousPriority;
const newPriority = event.target.priority;
console.log(
`The priority changed from ${previousPriority} to ${newPriority}.`,
);
});
```

A more complete live example can be found in [`prioritychange` event > Examples](/docs/Web/API/TaskSignal/prioritychange_event).

## Specifications

## Browser compatibility

source: MDN Web Docs mirror · page

Cite this

"TaskPriorityChangeEvent: previousPriority property". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/TaskPriorityChangeEvent/previousPriority

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·