Web standards
JavaScript standards
Section titled “JavaScript standards”The Cloudflare Workers runtime is built on top of the V8 JavaScript and WebAssembly engine. The Workers runtime is updated at least once a week, to at least the version of V8 that is currently used by Google Chrome's stable release. This means you can safely use the latest JavaScript features, with no need for transpilers.
All of the standard built-in objects ↗ supported by the current Google Chrome stable release are supported, with a few notable exceptions:
- For security reasons, the following are not allowed:
eval()
new Function
WebAssembly.compile
↗WebAssembly.compileStreaming
↗WebAssembly.instantiate
with a buffer parameter ↗WebAssembly.instantiateStreaming
↗
Date.now()
returns the time of the last I/O; it does not advance during code execution.
Web standards and global APIs
Section titled “Web standards and global APIs”The following methods are available per the Worker Global Scope ↗:
Base64 utility methods
Section titled “Base64 utility methods”-
atob()
- Decodes a string of data which has been encoded using base-64 encoding.
-
btoa()
- Creates a base-64 encoded ASCII string from a string of binary data.
Timers
Section titled “Timers”-
setInterval()
- Schedules a function to execute every time a given number of milliseconds elapses.
-
clearInterval()
- Cancels the repeated execution set using
setInterval()
↗.
- Cancels the repeated execution set using
-
setTimeout()
- Schedules a function to execute in a given amount of time.
-
clearTimeout()
- Cancels the delayed execution set using
setTimeout()
↗.
- Cancels the delayed execution set using
performance.timeOrigin
and performance.now()
Section titled “performance.timeOrigin and performance.now()”-
performance.timeOrigin
- Returns the high resolution time origin. Workers uses the UNIX epoch as the time origin, meaning that
performance.timeOrigin
will always return0
.
- Returns the high resolution time origin. Workers uses the UNIX epoch as the time origin, meaning that
-
performance.now()
- Returns a
DOMHighResTimeStamp
representing the number of milliseconds elapsed sinceperformance.timeOrigin
. Note that Workers intentionally reduces the precision ofperformance.now()
such that it returns the time of the last I/O and does not advance during code execution. Effectively, because of this, and becauseperformance.timeOrigin
is always,0
,performance.now()
will always equalDate.now()
, yielding a consistent view of the passage of time within a Worker.
- Returns a
EventTarget
and Event
Section titled “EventTarget and Event”The EventTarget
↗ and Event
↗ API allow objects to publish and subscribe to events.
AbortController
and AbortSignal
Section titled “AbortController and AbortSignal”The AbortController
↗ and AbortSignal
↗ APIs provide a common model for canceling asynchronous operations.
Fetch global
Section titled “Fetch global”-
fetch()
- Starts the process of fetching a resource from the network. Refer to Fetch API.
Encoding API
Section titled “Encoding API”Both TextEncoder
and TextDecoder
support UTF-8 encoding/decoding.
Refer to the MDN documentation for more information ↗.
The TextEncoderStream
↗ and TextDecoderStream
↗ classes are also available.
URL API
Section titled “URL API”The URL API supports URLs conforming to HTTP and HTTPS schemes.
Refer to the MDN documentation for more information ↗
Compression Streams
Section titled “Compression Streams”The CompressionStream
and DecompressionStream
classes support the deflate, deflate-raw and gzip compression methods.
Refer to the MDN documentation for more information ↗
URLPattern API
Section titled “URLPattern API”The URLPattern
API provides a mechanism for matching URLs based on a convenient pattern syntax.
Refer to the MDN documentation for more information ↗.
The Intl
API allows you to format dates, times, numbers, and more to the format that is used by a provided locale (language and region).
Refer to the MDN documentation for more information ↗.
navigator.userAgent
Section titled “navigator.userAgent”When the global_navigator
compatibility flag is set, the navigator.userAgent
↗ property is available with the value 'Cloudflare-Workers'
. This can be used, for example, to reliably determine that code is running within the Workers environment.
Unhandled promise rejections
Section titled “Unhandled promise rejections”The unhandledrejection
↗ event is emitted by the global scope when a JavaScript promise is rejected without a rejection handler attached.
The rejectionhandled
↗ event is emitted by the global scope when a JavaScript promise rejection is handled late (after a rejection handler is attached to the promise after an unhandledrejection
event has already been emitted).
addEventListener('unhandledrejection', (event) => { console.log(event.promise); // The promise that was rejected. console.log(event.reason); // The value or Error with which the promise was rejected.});
addEventListener('rejectionhandled', (event) => { console.log(event.promise); // The promise that was rejected. console.log(event.reason); // The value or Error with which the promise was rejected.});
navigator.sendBeacon(url[, data])
Section titled “navigator.sendBeacon(url[, data])”When the global_navigator
compatibility flag is set, the navigator.sendBeacon(...)
↗ API is available to send an HTTP POST
request containing a small amount of data to a web server. This API is intended as a means of transmitting analytics or diagnostics information asynchronously on a best-effort basis.
For example, you can replace:
const promise = fetch('https://example.com', { method: 'POST', body: 'hello world' });ctx.waitUntil(promise);
with navigator.sendBeacon(...)
:
navigator.sendBeacon('https://example.com', 'hello world');
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Products
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark