Optional
cacheThe Edgio hostname from which to prefetch cached content. This is only used when the origin site is not served from Edgio.
example.com
Optional
forceThe probability that a prefetch request will be relayed to the origin even if a response is not in the cache. Defaults to 0. This should be a number between 0 and 1.
Set to true to include pages not in the edge cache when prefetching. By default,
pages will only be prefetched if they are available in Edgio edge cache. Warning:
setting this to true
will cause a significant increase in traffic to the origin server.
Optional
observeThe prefetcher observes the DOM for new elements that are added for potential
prefetching. Observations are made to the document's child nodes and subtree.
Attributes changes are not observed by default, but can be enabled with
ObserveOptionsConfig.attributes
. Additionally, you can disable the observer
by setting ObserveOptionsConfig.disabled
to true
.
Optional
onThis function is called when the service worker is registered.
The ServiceWorkerRegistration object.
Optional
onThis function is called when the service worker state changes.
The ServiceWorkerRegistration object.
Optional
prefetchAny link whose href path matches one of these patterns will have its href prefetched when the link becomes visible
//products/(.+)/
Optional
prefetchURLsURLs to prefetch immediately
/products/123
Optional
serviceThe URL path on which the service worker is served.
/service-worker.js
Optional
serviceThe scope of the service worker.
'/'
Optional
watchA list of config objects with selectors to watch for. When elements matching the selector are found, the specified callback is called.
Example
install({
watch: [{
selector: 'div.product-tile',
callback: el => {
const productId = el.getAttribute('data-product-id')
const catId = document.getElementById('cat-listing').getAttribute('data-category-id')
prefetch(/api/${catId}/${productId}
, 'fetch')
}
}]
})
Generated using TypeDoc
Options for the
install
function.