2022-07-05 13:41:43 +00:00
---
sidebar_label: WebWorker
---
# WebWorker class
2022-08-10 21:34:29 +00:00
This class represents a [WebWorker ](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API ).
2022-07-05 13:41:43 +00:00
2022-10-24 07:07:05 +00:00
#### Signature:
2022-07-05 13:41:43 +00:00
```typescript
2023-12-15 12:08:28 +00:00
export declare abstract class WebWorker extends EventEmitter< Record < EventType , unknown > >
2022-07-05 13:41:43 +00:00
```
2023-11-13 12:27:17 +00:00
**Extends:** [EventEmitter ](./puppeteer.eventemitter.md )< Record< [EventType](./puppeteer.eventtype.md), unknown>>
2022-07-05 13:41:43 +00:00
## Remarks
The events `workercreated` and `workerdestroyed` are emitted on the page object to signal the worker lifecycle.
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `WebWorker` class.
## Example
```ts
page.on('workercreated', worker =>
console.log('Worker created: ' + worker.url())
);
page.on('workerdestroyed', worker =>
console.log('Worker destroyed: ' + worker.url())
);
console.log('Current workers:');
for (const worker of page.workers()) {
console.log(' ' + worker.url());
}
```
2023-04-19 09:00:08 +00:00
## Properties
2024-03-20 15:03:14 +00:00
< table > < thead > < tr > < th >
Property
< / th > < th >
Modifiers
< / th > < th >
Type
< / th > < th >
Description
< / th > < / tr > < / thead >
< tbody > < tr > < td >
2024-04-11 11:01:13 +00:00
< span id = "client" > client< / span >
2024-03-20 15:03:14 +00:00
< / td > < td >
`readonly`
< / td > < td >
[CDPSession ](./puppeteer.cdpsession.md )
< / td > < td >
The CDP session client the WebWorker belongs to.
< / td > < / tr >
< / tbody > < / table >
2023-04-19 09:00:08 +00:00
2022-07-05 13:41:43 +00:00
## Methods
2024-03-20 15:03:14 +00:00
< table > < thead > < tr > < th >
Method
< / th > < th >
Modifiers
< / th > < th >
Description
< / th > < / tr > < / thead >
< tbody > < tr > < td >
2024-04-11 11:01:13 +00:00
< span id = "close" > [close()](./puppeteer.webworker.close.md)< / span >
2024-03-20 15:03:14 +00:00
< / td > < td >
< / td > < td >
< / td > < / tr >
< tr > < td >
2024-04-11 11:01:13 +00:00
< span id = "evaluate" > [evaluate(func, args)](./puppeteer.webworker.evaluate.md)< / span >
2024-03-20 15:03:14 +00:00
< / td > < td >
< / td > < td >
Evaluates a given function in the [worker ](./puppeteer.webworker.md ).
< / td > < / tr >
< tr > < td >
2024-04-11 11:01:13 +00:00
< span id = "evaluatehandle" > [evaluateHandle(func, args)](./puppeteer.webworker.evaluatehandle.md)< / span >
2024-03-20 15:03:14 +00:00
< / td > < td >
< / td > < td >
Evaluates a given function in the [worker ](./puppeteer.webworker.md ).
< / td > < / tr >
< tr > < td >
2024-04-11 11:01:13 +00:00
< span id = "url" > [url()](./puppeteer.webworker.url.md)< / span >
2024-03-20 15:03:14 +00:00
< / td > < td >
< / td > < td >
The URL of this web worker.
< / td > < / tr >
< / tbody > < / table >