WorkerLocation.origin returns the worker’s origin as a string—scheme + host + port in origin form (no path, query, or hash). Per MDN, an example value is "https://developer.mozilla.org:443".
Read the notes below before you rely on this property. Prefer feature detection when support is limited.
Syntax
Use location.origin. Start with this line.
JavaScript
location.origin / self.location.origin
Call
What it does
location.origin / self.location.origin
Primary signature.
Built into Web Workers. Read self.location.origin (or location.origin) inside a worker — no import required.
Library declarations
JavaScript
location.origin / self.location.origin
Parameters
Parameter
Description
Worker context
Required. self.location is a WorkerLocation
Writable?
Optional. Read-only
Return Value
Return Value
Description
*
Origin string (or special blob/opaque cases)
JavaScript Examples
Example 1 — Read location.origin
Post the worker origin string (MDN idea).
JavaScript
// Inside a Web Worker
const result = self.location.origin;
// e.g. "https://developer.mozilla.org:443"
self.postMessage(result);
Blob URL. Object-URL workers use a blob: script address.
Protocol clue.location.protocol is typically "blob:".
Origin may be special. Some browsers expose an opaque origin as the string "null".
Debug tip. Always pair origin with href so you still see the full blob URL.
Compatibility
Browser Support
WorkerLocation.origin is marked Baseline Widely available on MDN (since September 2016). It is only available in Web Workers — not in Node.js, Bun, or Deno.
✓ Baseline · Widely available
WorkerLocation.origin
Supported across modern browsers with Web Workers. Read location.origin inside the worker.
98%Browser support
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Android WebViewSupported · Modern WebView
Full support
WorkerLocation.originExcellent
Bottom line: Browser / Web Workers only — not a Node.js API. Expect MDN-style origins on http(s) scripts; blob demos may print a special origin string.
Frequently Asked Questions
A string: the worker’s origin (scheme + host + port in origin form). Access it inside a worker as self.location.origin or location.origin.
No. MDN marks WorkerLocation.origin as Baseline Widely available (since September 2016). It is not Deprecated, Experimental, or Non-standard. It is only available in Web Workers.
href is the full serialized worker URL (path, query, hash included). origin is only the origin part—no path or fragment.
Blob worker origins can look different from http(s) workers (sometimes the string "null" for an opaque origin, depending on the URL and browser). Always log origin together with href when debugging.
No. WorkerLocation.origin is read-only.
Same idea (URL origin), different object. Inside a worker you read WorkerLocation via self.location—not the page’s Location.