Skip to Content
Performance Metrics

Performance Metrics — Page Timing via CDP

Foxbridge implements Performance.getMetrics by evaluating performance.timing in the page context, returning real browser timing data.

Usage

const client = await page.createCDPSession(); await client.send('Performance.enable'); const { metrics } = await client.send('Performance.getMetrics'); for (const { name, value } of metrics) { console.log(`${name}: ${value}`); }

Returned Metrics

MetricSourceDescription
TimestampDate.now() / 1000Current time in seconds
Documentsdocument.querySelectorAll('*').lengthTotal DOM element count
Frameswindow.frames.lengthNumber of frames
JSEventListenersConstant 0Not available in Firefox
DomContentLoadedperformance.timingTime to DOMContentLoaded (seconds)
NavigationStartperformance.timingNavigation start timestamp
DomInteractiveperformance.timingTime to DOM interactive (seconds)
FirstMeaningfulPaintperformance.timing.responseEndApproximated from response end
TaskDurationperformance.now() / 1000Page uptime in seconds
JSHeapUsedSizeperformance.memoryUsed JS heap (if available)
JSHeapTotalSizeperformance.memoryTotal JS heap (if available)

Timing-based metrics (DomContentLoaded, NavigationStart, DomInteractive, FirstMeaningfulPaint) are only included when the corresponding performance.timing values are non-zero.

Implementation

The metrics are collected via a single Runtime.evaluate call injected into the page. This avoids any protocol-level dependency on Chrome-specific performance APIs.

If evaluation fails (e.g., the page has no content), a fallback response with just Timestamp: 0 is returned.

Protocol Methods

MethodBehavior
Performance.enableNo-op (always available)
Performance.disableNo-op
Performance.getMetricsEvaluates JS and returns metrics array

See also

Last updated on