---
slug: /developers/architecture/browser-php-worker-threads
---
# PHP Worker Threads
PHP is always ran in a [web worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) to ensure the PHP runtime doesn't slow down the user interface of the main website.
Imagine the following code:
```js
```
As soon as you click that button the browser will freeze and you won't be able to type in the input. That's just how browsers work. Whether it's a for loop or a PHP server, running intensive tasks slows down the user interface.
### Initiating web workers
Web workers are separate programs that can process heavy tasks outside of the main application. They must be initiated by the main JavaScript program living in the browser tab. Here's how:
```ts
const phpClient = consumeAPI(
spawnPHPWorkerThread(
'/worker-thread.js' // Valid Worker script URL
)
);
await phpClient.isReady();
await phpClient.run({ code: `