Creates an instance of the Edgemesh Client.
Returns: Edgemesh
- Instance of the Edgemesh class.
Param | Type | Default | Description |
opts |
|
| Client configuration options. |
opts.lite |
|
| Lite mode disables the Edgemesh service worker. Customers that want to use Edgemesh only for its B2B Analyzer and Real User Metrics will want to set this to |
opts.externalMount |
|
| External Mount mode instructs the Edgemesh client that it should skip registration of its own service worker and instead look for an externally mounted, Edgemesh compatible service worker. This is used by our partners to integrate Edgemesh into their services. |
opts.softDisable |
|
| By default, when Edgemesh encounters an unrecoverable error or a site is disabled by configuration, the Edgemesh Service Worker is unregistered. This can cause unintended side affects if you are combining service workers. Soft Disable keeps the installed Service Worker alive, only disabling the Edgemesh service itself. |
opts.swUrl |
|
| URL of the Edgemesh service worker. This options is used by Edgemesh integrations. You can add your service worker to a sub-directory and set this option, just make sure you know what you are doing. |
opts.scope |
|
| Scope of the Edgemesh service worker. Change the scope at which the service worker is allowed to service. More on that here. |
opts.host |
|
| Host of the Edgemesh back end. Don't change this unless instructed by your dedicated Edgemesh Engineer (Enterprise feature). |
opts.topicDepth |
|
| If your domain has different websites on subdirectories, you can use |
Set the Edgemesh log level.
Param | Type | Description |
level |
| The integer representation of the Edgemesh log level. |
Example
// Disable Logging.window.edgemesh.setLogLevel(window.edgemesh.LOG_LEVELS.silent)​// Error Logging.window.edgemesh.setLogLevel(window.edgemesh.LOG_LEVELS.error)​// Warning Logging.window.edgemesh.setLogLevel(window.edgemesh.LOG_LEVELS.warn)​// Info Logging.window.edgemesh.setLogLevel(window.edgemesh.LOG_LEVELS.log)​// Verbose Logging.window.edgemesh.setLogLevel(window.edgemesh.LOG_LEVELS.debug)
Enable and disable developer mode. Developer mode disables the Edgemesh service worker for your browser, preventing new assets from being registered.
Param | Type | Description |
enabled |
| Enable or disable devmode. |
Example
// Enable devmode.window.edgemesh.devmode(true)​// Disable devmode.window.edgemesh.devmode(false)
Calling the sync method will instruct the Edgemesh client to perform a background sync. By default, Edgemesh initates a background sync when the DOM has completed loading all it's required content. This method is provided if you want to hook background sync functionality into your own application or perform a sync on your own browser from the javascript console.
Param | Type | Default | Description |
type |
|
| The type of sync operation. One of |
// Perform a full Edgemesh backround sync.edgemesh.sync()​// Perform a sync that removes all stale assetsedgemesh.sync('del')​// Perform a sync that adds new assetsedgemseh.sync('add')
The stats 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.
Key | Type | Description |
ready | Boolean | Wether or not the Edgemesh analytics client is ready. |
workerEnabled | Boolean | Wether or not the Edgemesh service worker is enabled and activated. |
percentAccelerated | Number | The percentage of total resources that Edgemesh was able to serve from cache. |
cacheHitCount | Number | The number of resources that were served from the Edgemesh cache. |
cacheMissCount | Number | The number of resources that were served from Origin. |
// Get the Edgemesh Statisticsedgemesh.stats()​// {// ready: true,// workerEnabled: true,// percentAccelerated: 79,// cacheHitCount: 19,// cacheMissCount: 5// }
Edgemesh Log Levels
Name | Type | Description | Default |
debug |
| Log everything. | 0 |
log |
| Log info, warnings and errors. | 1 |
warn |
| Log warnings and errors. | 2 |
error |
| Log errors. | 3 |
silent |
| Disable logs. | 4 |
​