@cloudflare/speedtest is the JavaScript SDK that powers speed.cloudflare.com. Embed it in any web application to measure your users’ real connection quality with a single import.
Quick Start
Get a working speed test running in minutes
Configuration
Customize measurements, APIs, and thresholds
Results API
Access bandwidth, latency, jitter, and packet loss data
AIM Scores
Network quality scores for streaming, gaming, and video calls
Packet Loss
Measure UDP packet loss via WebRTC TURN
API Reference
Full class and method reference
How it works
The SDK performs a sequence of HTTP requests against Cloudflare’s edge network and uses the browser’sPerformanceResourceTiming API to extract precise timing data. It characterizes your connection across five dimensions:
- Download bandwidth — measured by fetching files of increasing sizes
- Upload bandwidth — measured by posting payloads of increasing sizes
- Latency — round-trip time at idle (unloaded) and under load
- Jitter — variability in consecutive latency measurements
- Packet loss — UDP packet loss ratio via a WebRTC TURN server
Measurement results are collected by Cloudflare on completion for the purpose of calculating aggregated Internet quality insights.
