JavaScript and web standards
The Workers runtime provides the following standardized APIs for use by scripts running at the edge.
JavaScript standards
Cloudflare Workers uses the V8 JavaScript engine from Google Chrome. The Workers runtime is updated at least once a week, to at least the version that is currently used by 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:
eval()
is not allowed for security reasons.new Function
is not allowed for security reasons.Date.now()
returns the time of the last I/O; it does not advance during code execution.
Web global APIs
The following methods are available per the Worker Global Scope:
Base64 utility methods
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
Fetch global
Encoding API
Both TextEncoder and TextDecoder support UTF-8 encoding/decoding.
URL API
The URL API supports urls conforming to http and https schemes.