---
title: WorkerLocation
summary: The absolute location of the script executed by the Worker.
url: https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/interface.WorkerLocation/
---

**Kind:** Interface  
**Module:** [globals](https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/)  
**Package:** @fastly/js-compute 4.0.1  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2234

The absolute location of the script executed by the Worker.

Available via the global [location](https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/) property.

**See also**

- [WorkerLocation on MDN](https://developer.mozilla.org/en-US/docs/Web/API/WorkerLocation)

## Constructor

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2265

```javascript
new WorkerLocation()
```

The WorkerLocation class as [specified by WHATWG](https://html.spec.whatwg.org/multipage/workers.html#worker-locations)

**See also**

- [WorkerLocation on MDN](https://developer.mozilla.org/en-US/docs/Web/API/WorkerLocation)

## Properties

### hash

**Type:** `string`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2236

The fragment identifier (`#` followed by the fragment) of the worker's URL.

### host

**Type:** `string`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2238

The host (hostname and port) of the worker's URL.

### hostname

**Type:** `string`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2240

The hostname of the worker's URL.

### href

**Type:** `string`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2242

The serialized URL of the worker's location.

### origin

**Type:** `string`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2246

The origin of the worker's URL.

### pathname

**Type:** `string`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2248

The pathname of the worker's URL.

### port

**Type:** `string`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2250

The port of the worker's URL.

### protocol

**Type:** `string`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2252

The protocol scheme of the worker's URL.

### search

**Type:** `string`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2254

The query string (`?` followed by parameters) of the worker's URL.

## Methods

### toString

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2244

```javascript
toString(): string
```

Returns the serialized URL. Synonym for [WorkerLocation.href](https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/interface.WorkerLocation/).

**Returns**

`string`
