Overview
ConfigOptions is the TypeScript interface for the optional configuration object passed to new SpeedTest(config). Every field is optional — omitting a field uses the documented default.
Engine control
Whether to call
play() automatically when the engine is instantiated. Set
to false to construct the engine without starting measurements and call
play() manually when ready.API endpoints
URL used for download GET requests and latency probes. The engine appends a
bytes query parameter to request files of specific sizes (e.g.
?bytes=1000000).URL used for upload POST requests. The engine posts binary payloads of
specific sizes to this endpoint.
URI of the TURN server used for packet loss measurements. The engine connects
to this server via WebRTC to send and receive UDP packets.
URL of an endpoint that returns short-lived TURN server credentials as a JSON
response. The response must include
username and credential string fields
and may optionally include a urls array of TURN server addresses. Used as
an alternative to providing static credentials via turnServerUser and
turnServerPass. See TURN server setup for
a reference implementation.This option is accepted by the constructor but is not yet included in the
published TypeScript type definitions. Use a type assertion
(
config as any) if you encounter type errors.Static TURN server username. Use this together with
turnServerPass when
your TURN server requires static credentials.Static TURN server password. Use this together with
turnServerUser when
your TURN server requires static credentials.Whether to include cookies and HTTP authentication credentials in download
and upload fetch requests (
credentials: 'include'). Enable this if your
API endpoints require authenticated requests.Measurement control
The ordered sequence of measurements the engine performs. Each element is a
MeasurementConfig object with a type field plus type-specific fields.Omitting this field uses the built-in default sequence, which ramps up from
small latency probes through progressively larger download and upload sizes,
followed by a packet loss test.Each measurement type accepts the following fields:- latency
- download / upload
- packetLoss
| Field | Required | Type | Description |
|---|---|---|---|
type | yes | "latency" | Measurement type. |
numPackets | yes | number | Number of latency GET requests to perform against the download API with bytes=0. Round-trip TTFB is extracted from PerformanceResourceTiming. |
Whether to measure latency in parallel with active download requests (loaded
latency in the download direction). Results are accessible via
results.getDownLoadedLatency().Whether to measure latency in parallel with active upload requests (loaded
latency in the upload direction). Results are accessible via
results.getUpLoadedLatency().Minimum time in milliseconds to wait between loaded latency probe requests.
Increasing this value reduces the number of latency samples collected during
bandwidth measurements.
Target request duration in milliseconds. When the engine completes a
download or upload measurement set and the observed request duration exceeds
this value, it considers that transfer size sufficient and skips any
remaining measurement sets for the same direction.This implements the ramp-up strategy: small file sizes are tested first, and
once requests take long enough the engine stops increasing the file size.
Maximum request duration in milliseconds before the engine aborts the
current measurement set early and stops further measurements in that
direction. A value of
0 disables early abort.Use this to cap test duration on very slow connections.Fixed server processing time in milliseconds subtracted from all
time-to-first-byte calculations when the server does not return a
Server-Timing response header. Adjust this if you use a custom API
endpoint with a different processing baseline.Result calculation
Percentile (between
0 and 1) used to reduce the set of raw latency
measurements to a single value. The default of 0.5 returns the median.
Lower values produce more optimistic results; higher values are more
conservative.Percentile (between
0 and 1) used to reduce the set of raw bandwidth
measurements to a single value. The default of 0.9 reflects near-peak
throughput while excluding outliers at the extreme high end.Minimum request duration in milliseconds for a download or upload sample to
be included in the bandwidth calculation. Samples from requests that
complete faster than this threshold are discarded as unreliable.
Minimum request duration in milliseconds for a bandwidth request to be
considered as genuinely loading the connection. Loaded latency samples are
only recorded alongside requests that meet this threshold.
Maximum number of loaded latency data points to retain per direction. When
more samples are available the most recent ones are kept and earlier ones are
discarded.
