Methods

The following methods can be called using the global edgemesh variable in your own javascript or from the developer tools javascript console.

setLogLevel

Sets the Edgemesh log level for the service worker and client. This will give you visibility into how Edgemesh is routing requests and transferring data.

Signature
public setLogLevel (level: LogLevel): void

Arguments


The LogLevel to set the Edgemesh logger to.
LogLevel
SILENT Disables all Edgemesh® logs.
ERROR Log only errors.
WARN Log warnings and errors.
INFO Log information, warnings, and errors.
INFO Log all logs, including verbose debugging logs.
Disable Logging
edgemesh.setLogLevel(edgemesh.LogLevels.SILENT)
Error Logging
edgemesh.setLogLevel(edgemesh.LogLevels.ERROR)
Warning Logging
edgemesh.setLogLevel(edgemesh.LogLevels.WARN)
Info Logging
edgemesh.setLogLevel(edgemesh.LogLevels.LOG)
Debug Logging
edgemesh.setLogLevel(edgemesh.LogLevels.DEBUG)

setDevMode

Enable and disable developer mode. Developer mode disables the Edgemesh service worker for your browser, allowing you to effectively bypass the Edgemesh Cache until developer mode is disabled.

Signature
public setDevMode (enable: boolean): string

Arguments


enable
boolean
Enable or disable developer mode.
Enable Developer Mode
window.edgemesh.setDevMode(true)
Disable Developer Mode
window.edgemesh.setDevMode(false)

setDebugMode

Enable and disable debug mode. Debug mode is a tool for Edgemesh support that changes the data transport to a human-readable format.

Signature
public setDevMode (enable: boolean): string

Arguments


enable
boolean
Enable or disable debug mode.
Enable Debug Mode
window.edgemesh.setDebugMode(true)
Disable Debug Mode
window.edgemesh.setDebugMode(false)

loadScripts

The loadScripts method is responsible for querying the DOM for scripts optimized with the Script Loader and processing them. It is automatically invoked when the Edgemesh® Client loads. However, we provide the flexibility for you to call it programmatically when necessary.

Signature
public loadScripts (): void
Load Scripts
edgemesh.loadScripts()

getStats

The getStats method returns a dictionary of Edgemesh relevant statistics. This is useful for integrating with third-party analytics platforms. This method is best called after the onload or onpageshow events to ensure all resources are captured.

Signature
public getStats (): IStats

Returns


ready
boolean
Whether or not the Edgemesh analytics client is ready.

Whether or not the Edgemesh service worker is enabled and activated.

The percentage of total resources that Edgemesh was able to serve from cache.

The number of resources that were served from the Edgemesh cache.

The number of resources that were served from Origin.
Get Statistics
edgemesh.getStats()
Example Return
{
ready: true,
workerEnabled: true,
percentAccelerated: 79,
cacheHitCount: 19,
cacheMissCount: 5
}

flare

Send a flare to Edgemesh support staff. Optionally takes a message to include with your flare. This method returns a flareId that you should give to your Edgemesh support agent so they can better assist you.

Signature
public flare (message?: string): string

Arguments


message
string
OPTIONAL
Message to include with support flare.
Send a Flare
edgemesh.flare()
Send a Flare with a Message
edgemesh.flare('More information about the problem you are having.')
Copy flareId to Clipboard
copy(edgemesh.flare())
Example Flare ID
🔥 kf9a40lg36k

metrics

The Edgemesh® Client real user metrics can be accessed via the edgemesh.metrics namespace and integrated with other workflows/reporters.

getTTFB

Time to First Byte (TTFB) is a foundational metric for measuring connection setup time and web server responsiveness in both the lab and the field. It helps identify when a web server is too slow to respond to requests. In the case of navigation requests, it precedes every other meaningful loading performance metric.

TTFB is a metric that measures the time between the request for a resource and when the first byte of the response begins to arrive. Since TTFB precedes user-centric metrics such as First Contentful Paint (FCP) and Largest Contentful Paint (LCP), it's recommended that your server responds to navigation requests quickly enough so that the 75th percentile of users experience an FCP within the "good" threshold. As a rough guide, most sites should strive to have a time to first byte of 0.8 seconds or less.

More about Time to First Byte can be found here.

Signature
public getTTFB (): IMetric

Returns


name
string
The name of the metric. This value will always be "TTFB".

value
number
The time to first byte in milliseconds.

delta
number
The change in time between navigation events. This value applies to client-side routing and will always be 0 for sever-side rendered websites.

entries
PerformanceNavigationTiming[]
The Performance Navigation Timing records used to determine this metric.
Get Time to First Byte
edgemesh.metrics.getTTFB()
Example Return
{
name: "TTFB",
value: 87,
delta: 0,
entries: [{
name: "https://example.com/",
entryType: "navigation",
startTime: 0,
duration: 2350.7999999523163,
initiatorType: "navigation",
nextHopProtocol: "h2",
workerStart: 0,
redirectStart: 0,
redirectEnd: 0,
fetchStart: 7.400000095367432,
domainLookupStart: 7.400000095367432,
domainLookupEnd: 7.400000095367432,
connectStart: 7.400000095367432,
connectEnd: 7.400000095367432,
secureConnectionStart: 7.400000095367432,
requestStart: 25,
responseStart: 87.10000014305115,
responseEnd: 90.40000009536743,
transferSize: 8993,
encodedBodySize: 8693,
decodedBodySize: 32501,
serverTiming: [
{
name: "ems-cache-hit",
duration: 0,
description: "Cache Hit"
},
{
name: "ems-parse-url",
duration: 0,
description: "Parse URL"
},
{
name: "ems-get-config",
duration: 0,
description: "Get Config"
},
{
name: "ems-cache-lookup",
duration: 11,
description: "Cache Lookup"
}
],
unloadEventStart: 102.20000004768372,
unloadEventEnd: 102.20000004768372,
domInteractive: 663.4000000953674,
domContentLoadedEventStart: 663.4000000953674,
domContentLoadedEventEnd: 673.4000000953674,
domComplete: 2347.7999999523163,
loadEventStart: 2347.9000000953674,
loadEventEnd: 2350.7999999523163,
type: "reload",
redirectCount: 0
}]
}

getCLS

Cumulative Layout Shift (CLS) is an important, user-centric metric for measuring visual stability because it helps quantify how often users experience unexpected layout shifts—a low CLS helps ensure that the page is delightful.

CLS is a measure of the largest burst of layout shift scores for every unexpected layout shift that occurs during the entire lifespan of a page. A layout shift occurs any time a visible element changes its position from one rendered frame to the next.

More about Cumulative Layout Shift can be found here.

Signature
public getCLS (): IMetric

Returns


name
string
The name of the metric. This value will always be "CLS".

value
number
The aggregated CLS score. A good CLS score is below 0.1.

delta
number
The change in score between navigation events. This value applies to client side routing and will always be 0 for sever-side rendered websites.

entries
LayoutShift[]
The Layout Shift entries that were used to calculate this metric.
Get Cumulative Layout Shift
edgemesh.metrics.getCLS()
Example Return
{
name: "CLS",
value: 0.014961858712264948,
delta: 0,
entries: [{
name: "",
entryType: "layout-shift",
startTime: 3268.5,
duration: 0,
value: 0.0008666364169288759,
hadRecentInput: false,
lastInputTime: 1993.4000000953674,
sources: [
{
previousRect: {
x: 1890,
y: 1936,
width: 32,
height: 32,
top: 1936,
right: 1922,
bottom: 1968,
left: 1890
},
currentRect: {
x: 1722,
y: 1776,
width: 200,
height: 192,
top: 1776,
right: 1922,
bottom: 1968,
left: 1722
}
}
]
}, {
name: "",
entryType: "layout-shift",
startTime: 3465.4000000953674,
duration: 0,
value: 0.014095222295336073,
hadRecentInput: false,
lastInputTime: 1993.4000000953674,
sources: [
{
previousRect: {
x: 1722,
y: 1776,
width: 200,
height: 192,
top: 1776,
right: 1922,
bottom: 1968,
left: 1722
},
currentRect: {
x: 1370,
y: 1428,
width: 552,
height: 540,
top: 1428,
right: 1922,
bottom: 1968,
left: 1370
}
}
]
}]
}

getFCP

First Contentful Paint (FCP) is an important, user-centric metric for measuring perceived load speed because it marks the first point in the page load timeline where the user can see anything on the screen—a fast FCP helps reassure the user that something is happening.

The FCP metric measures the time from when the page starts loading to when any part of the page's content is rendered on the screen. For this metric, "content" refers to text, images (including background images), <svg> elements, or non-white <canvas> elements. To provide a good user experience, sites should strive to have a First Contentful Paint of 1.8 seconds or less.

More about First Contentful Paint can be found here.

Signature
public getFCP (): IMetric

Returns


name
string
The name of the metric. This value will always be "FCP".

value
number
The FCP time in milliseconds.

delta
number
The change in time between navigation events. This value applies to client-side routing and will always be 0 for sever-side rendered websites.

entries
PerformancePaintTiming[]
The Performance Paint Timing entries that were used to calculate this metric.
Get First Contentful Paint
edgemesh.metrics.getFCP()
Example Return
{
name: "FCP",
value: 997.3000001907349,
delta: 0,
entries: [{
name: "first-contentful-paint",
entryType: "paint",
startTime: 997.3000001907349,
duration: 0
}]
}

getFID

First Input Delay (FID) is an important, user-centric metric for measuring load responsiveness because it quantifies the experience users feel when trying to interact with unresponsive pages. A low FID helps ensure that the page is usable.

FID measures the time from when a user first interacts with a page (i.e. when they click a link, tap on a button, or use a custom, JavaScript-powered control) to the time when the browser can begin processing event handlers in response to that interaction. To provide a good user experience, sites should strive to have a First Input Delay of 100 milliseconds or less.

More about First Input Delay can be found here.

Signature
public getFID (): IMetric

Returns


name
string
The name of the metric. This value will always be "FID".

value
number
The FID time in milliseconds.

delta
number
The change in time between navigation events. This value applies to client-side routing and will always be 0 for sever-side rendered websites.

entries
PerformanceEventTiming[]
The Performance Event Timing entries that were used to calculate this metric.
Get First Input Delay
edgemesh.metrics.getFID()
Example Return
{
name: "FID",
value: 6.3999998569488525,
delta: 0,
entries: [{
name: "keydown",
entryType: "first-input",
startTime: 1038.6000001430511,
duration: 16,
processingStart: 1045,
processingEnd: 1045.1000001430511,
cancelable: true,
target: body
}]
}

getLCP

Largest Contentful Paint (LCP) is an important, user-centric metric for measuring perceived load speed because it marks the point in the page load timeline when the page's main content has likely loaded—a fast LCP helps reassure the user that the page is useful.

The Largest Contentful Paint (LCP) metric reports the render time of the largest image or text block visible within the viewport, relative to when the page first started loading. To provide a good user experience, sites should strive to have a largest contentful Paint of 2.5 seconds or less.

More about Largest Contentful Paint can be found here.

Signature
public getLCP (): IMetric

Returns


name
string
The name of the metric. This value will always be "LCP".

value
number
The LCP time in milliseconds.

delta
number
The change in time between navigation events. This value applies to client-side routing and will always be 0 for sever-side rendered websites.

entries
LargestContentfulPaint[]
The Largest Contentful Paint entries that were used to calculate this metric.
Get Largest Contentful Paint
edgemesh.metrics.getLCP()
Example Return
{
name: "LCP",
value: 997.4,
delta: 0,
entries: [{
name: "",
element img.banner#hero,
entryType: "largest-contentful-paint",
startTime: 997.4,
duration: 0,
size: 119957,
renderTime: 997.4,
loadTime: 0,
id: "hero",
url: "https://example.com/image.png"
}]
}

getTBT

Total Blocking Time (TBT) is an important metric for measuring load responsiveness because it helps quantify the severity of how non-interactive a page is before it becomes reliably interactive. A low TBT helps ensure that the page is usable.

The TBT metric measures the total amount of time between First Contentful Paint (FCP) and Time to Interactive (TTI) where the main thread was blocked for long enough to prevent input responsiveness. To provide a good user experience, sites should strive to have a Total Blocking Time of less than 200 milliseconds when tested on average mobile hardware.

More about Total Blocking Time can be found here.

Signature
public getTBT (): IMetric

Returns


name
string
The name of the metric. This value will always be "TBT".

value
number
The TBT in milliseconds.

delta
number
The change in time between navigation events. This value applies to client-side routing and will always be 0 for sever-side rendered websites.

entries
PerformanceLongTaskTiming[]
The Performance Long Task Timing entries that were used to calculate this metric.
Get Total Blocking Time
edgemesh.metrics.getTBT()
Example Return
{
name: "TBT",
value: 5,
delta: 0,
entries: [{
name: "self",
entryType: "longtask",
startTime: 433.2000000476837,
duration: 55,
attribution: [{
name: "unknown",
entryType: "taskattribution",
startTime: 0,
duration: 0,
containerType: "window",
containerSrc: "",
containerId: "",
containerName: ""
}]
}]
}

getTTI

Time to Interactive (TTI) is an important metric for measuring load responsiveness. It helps identify cases where a page looks interactive but is not. A fast TTI helps ensure that the page is usable.

The TTI metric measures the time from when the page starts loading to when its main sub-resources have loaded and it is capable of reliably responding to user input quickly. To provide a good user experience, sites should strive to have a Time to Interactive of less than 5 seconds when tested on average mobile hardware.

More about Time to Interactive can be found here.

Signature
public getTTI (): IMetric

Returns


name
string
The name of the metric. This value will always be "TTI".

value
number
The time to interactive in milliseconds.

delta
number
The change in time between navigation events. This value applies to client-side routing and will always be 0 for sever-side rendered websites.

entries
PerformanceNavigationTiming[]
The Performance Navigation Timing records used to determine this metric.
Get Time to Interactive
edgemesh.metrics.getTTI()
Example Return
{
name: "TTI",
value: 663,
delta: 0,
entries: [{
name: "https://example.com/",
entryType: "navigation",
startTime: 0,
duration: 2350.7999999523163,
initiatorType: "navigation",
nextHopProtocol: "h2",
workerStart: 0,
redirectStart: 0,
redirectEnd: 0,
fetchStart: 7.400000095367432,
domainLookupStart: 7.400000095367432,
domainLookupEnd: 7.400000095367432,
connectStart: 7.400000095367432,
connectEnd: 7.400000095367432,
secureConnectionStart: 7.400000095367432,
requestStart: 25,
responseStart: 87.10000014305115,
responseEnd: 90.40000009536743,
transferSize: 8993,
encodedBodySize: 8693,
decodedBodySize: 32501,
serverTiming: [
{
name: "ems-cache-hit",
duration: 0,
description: "Cache Hit"
},
{
name: "ems-parse-url",
duration: 0,
description: "Parse URL"
},
{
name: "ems-get-config",
duration: 0,
description: "Get Config"
},
{
name: "ems-cache-lookup",
duration: 11,
description: "Cache Lookup"
}
],
unloadEventStart: 102.20000004768372,
unloadEventEnd: 102.20000004768372,
domInteractive: 663.4000000953674,
domContentLoadedEventStart: 663.4000000953674,
domContentLoadedEventEnd: 673.4000000953674,
domComplete: 2347.7999999523163,
loadEventStart: 2347.9000000953674,
loadEventEnd: 2350.7999999523163,
type: "reload",
redirectCount: 0
}]
}

getCPUIdle

Both First CPU Idle and Time to Interactive measure when the page is ready for user input. First CPU Idle occurs when the user can start to interact with the page; TTI occurs when the user is fully able to interact with the page.

First CPU Idle measures how long it takes a page to become minimally interactive. A page is considered minimally interactive when most (but not necessarily all) UI elements on the screen are interactive and the page responds, on average, to most user input in a reasonable amount of time. To provide a good user experience, sites should strive to have a First CPU Idle of 4.7 seconds or less.

More about First CPU Idle can be found here.

Signature
public getCPUIdle (): IMetric

Returns


name
string
The name of the metric. This value will always be "FirstCPUIdle".

value
number
The First CPU Idle time in milliseconds.

delta
number
The change in time between navigation events. This value applies to client-side routing and will always be 0 for sever-side rendered websites.

entries
void[]
This array will always be empty.
Get First CPU Idle
edgemesh.metrics.getCPUIdle()
Example Return
{
name: "FirstCPUIdle",
value: 1146.6000001430511,
delta: 0,
entries: []
}

getLoadTime

Load time measures how long it takes a page to become "fully loaded". A page is considered fully loaded when the onload event is emitted. To provide a good user experience, sites should strive to have a load time of 3 seconds or less.

Signature
public getLoadTime (): IMetric

Returns


name
string
The name of the metric. This value will always be "OnLoad".

value
number
The load time in milliseconds.

delta
number
The change in time between navigation events. This value applies to client-side routing and will always be 0 for sever-side rendered websites.

entries
void[]
This array will always be empty.
Get On Load Time
edgemesh.metrics.getLoadTime()
Example Return
{
name: "OnLoad",
value: 2947.300000190735,
delta: 0,
entries: []
}

getInputDelay

Input delay measures the time from the initial page request to the time the main user interactions occur. These interactions include click, scroll, mousemove, and keypress. This metric is used to gain insight into how and when a user interacts with a given page. These values will be -1 if the event has not occurred at the time of measuring.

Signature
public getInputDelay (): IInputDelay

Returns


The first click event after the start of the page load in milliseconds.

The first scroll event after the start of the page load in milliseconds.

The first keypress event after the start of the page load in milliseconds.

The first mousemove event after the start of the page load in milliseconds.
Get First Input Delay
edgemesh.metrics.getInputDelay()
Example Return
{
firstClick: 3733.2999999523163,
firstScroll: 2289.7000000476837,
firstKeypress: 5047.2000000476837,
firstMousemove: 1160.7999999523163
}

getNavigation

Navigation metrics measure the performance of all the processes that make up page navigation. In addition, it returns the size of the data transferred during the navigation. Optional properties are omitted if they are null.

Signature
public getNavigation (): INavigation

Returns


url
string
The url of this navigation.

referrer
string
OPTIONAL
The referrer for this navigation.

proto
string
OPTIONAL
The protocol used for this navigation.

navType
number
OPTIONAL
The navigation type of this navigation. The value is an integer that maps to the below types:
  • 0: Navigate - A typical navigation.
  • 1: Reload - A page reload.
  • 2: Back/Forward - Back or forward navigation.
  • 3: Prerender - A pre-render navigation.

OPTIONAL
The time spent processing in a service worker.

dnsTime
number
The time it takes to resolve the DNS for the navigation in milliseconds.

sslTime
number
OPTIONAL
The time it takes for the TLS negotiation in milliseconds.

tcpTime
number
The time it takes to negotiate the connection in milliseconds.

reqTime
number
The time it takes to request the navigation in milliseconds.

resTime
number
The time it takes to respond to the navigation request in milliseconds.

fetchTime
number
The time it takes to fully fetch the navigation in milliseconds.

The time it takes to unload the page in milliseconds.

The time it takes to start rendering the page in milliseconds.

The time it takes to load all the content on the page in milliseconds.

pageLoad
number
The time it took for the DOM to be complete in milliseconds.

The time the user has spent on the page in milliseconds.

encSize
number
OPTIONAL
The size (in bytes) received from the fetch (HTTP or cache), of the payload body, before removing any applied content-codings.

decSize
number
OPTIONAL
The size (in bytes) received from the fetch (HTTP or cache) of the message body, after removing any applied content-codings. If the resource is retrieved from an application cache or local resources, it returns the size of the payload after removing any applied content-codings.

transSize
number
OPTIONAL
The size (in bytes) of the fetched resource. The size includes the response header fields plus the response payload body.

bad
boolean
OPTIONAL
Signifies that an anomaly was detected and this data should not be trusted.
Get Navigation Metrics
edgemesh.metrics.getNavigation()
Example Return
{
"url": "https://example.com/",
"referrer": "https://foo.com/",
"timeOnPage": 156879,
"workerTime": 0,
"dnsTime": 0,
"sslTime": 0,
"tcpTime": 0,
"reqTime": 62,
"resTime": 3,
"fetchTime": 83,
"unloadTime": 0,
"startRender": 663,
"contentLoaded": 673,
"pageLoad": 2348,
"navType": 1,
"proto": "h2",
"encSize": 8693,
"decSize": 32501,
"transSize": 8993
}

getResources

Resource metrics measure the performance of all the processes that make up a resource request. Resources are the individual facets that make up a page (scripts, stylesheets, images, fonts, etc...). Optional properties, when null, will be xxx for strings and -1 for numbers.

Signature
public getResources (): IResource[]

Returns


url
string
The url of this resource.

oid
string
A 64 bit hash of the url origin.

aid
string
A 64 bit hash of the url pathname and search params.

type
string
The type of resource that initiated the resource request.
  • If the initiator is a Element, the property returns the element's localName.
  • If the initiator is a CSS resource, the property returns "css".
  • If the initiator is a XMLHttpRequest object, the property returns "xmlhttprequest".
  • If the initiator is a PerformanceNavigationTiming object, the property returns an empty string ("").

proto
string
OPTIONAL
The protocol used for this resource.

cached
number
The cache status of this resource. The value is a number that maps to the following:
  • 0: Origin - This resource was not cached in the Edgemesh® Client cache and was fetched from the origin server.
  • 1: Cached - This resource was cached in the Edgemesh® Client cache.

OPTIONAL
The time spent processing in a service worker.

dnsTime
number
The time it takes to resolve the DNS for the resource in milliseconds.

sslTime
number
OPTIONAL
The time it takes for the TLS negotiation in milliseconds.

tcpTime
number
The time it takes to negotiate the connection in milliseconds.

reqTime
number
The time it takes to request the resource in milliseconds.

resTime
number
The time it takes to respond to the resource request in milliseconds.

fetchTime
number
The time it takes to fully fetch the resource in milliseconds.

startTime
number
The time since initial navigation that the resource request started.

encSize
number
OPTIONAL
The encoded body size in bytes.

decSize
number
OPTIONAL
The decoded body size in bytes.

transSize
number
OPTIONAL
The transferred body size in bytes.
Get Resource Metrics
edgemesh.metrics.getResources()
Example Return
[{
url: "https://example.com/style.css",
oId: "0x07ef265a7937d6ba",
aId: "0x450e0cae420aa2c8",
type: "link",
proto: "h2",
cached: 1,
workerTime: 3
dnsTime: 0,
sslTime: 0,
tcpTime: 0,
reqTime: 2,
resTime: 1,
fetchTime: 3,
startTime: 121,
encSize: 0,
decSize: 0,
transSize: 0
}, ...]

Made withby Edgemesh Corporation