{TametheBots}

serviceWorker API

The Result:

Service Worker?

JavaScript Not Functioning

Testing if the serviceWorker API exisits, and if it can register a service worker.

There is a script at the bottom of the page, it attempts to register a service worker and updates the result p tag with the outcome.

<script>
window.addEventListener('load', function (loadEvent) {
if (window.navigator.serviceWorker) {
addRes('1 - window.navigator.serviceWorker TRUE');
navigator.serviceWorker.register('/sw.js').then(function (registration) {
addRes('2 - Service Worker Registered');
}, function (err) {
addRes('2 - Service Worker Register Fail');
})
} else {
addRes('1 - window.navigator.serviceWorker FALSE');
}
})
function addRes(mess) {
let cur = document.getElementById("result").innerHTML;
document.getElementById("result").innerHTML = cur + '<br />' + mess;
}
</script>

< Back