WorkerLocation.protocol returns the protocol (scheme) part of the worker’s location as a string. Per MDN, on an https: worker page, location.protocol is "https:" (trailing colon included).
Read the notes below before you rely on this property. Prefer feature detection when support is limited.
Syntax
Use location.protocol. Start with this line.
JavaScript
location.protocol
Call
What it does
location.protocol
Primary signature.
Built into Web Workers. Read self.location.protocol (or location.protocol) inside a worker — no import required.
Library declarations
JavaScript
location.protocol
Parameters
Parameter
Description
Worker context
Required. self.location is a WorkerLocation
Trailing :
Required. Use "https:", not "https"
Flag clearly.protocol === "blob:" is a simple boolean check.
Debug tip. Pair with href when the scheme looks unexpected.
Compatibility
Browser Support
WorkerLocation.protocol is marked Baseline Widely available on MDN (since July 2015). It is only available in Web Workers — not in Node.js, Bun, or Deno.
✓ Baseline · Widely available
WorkerLocation.protocol
Supported across modern browsers with Web Workers. Read location.protocol 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.protocolExcellent
Bottom line: Browser / Web Workers only — not a Node.js API. Expect MDN-style "https:" on https worker scripts; blob demos usually print "blob:".
Frequently Asked Questions
A string: the protocol (scheme) part of the worker’s location, usually with a trailing colon—for example "https:" or "blob:". Access it inside a worker as self.location.protocol or location.protocol.
No. MDN marks WorkerLocation.protocol as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard. It is only available in Web Workers.
URL protocol strings conventionally include the trailing colon, so you get "https:" rather than "https". Compare with === "https:" when checking.
protocol is only the scheme (with colon). origin combines scheme, host, and port into one origin string.
Blob workers usually report "blob:". Always log protocol together with href when debugging.