A very simple setup.
- Importing service worker file within
<script>
tag in index.html like so:
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/app/static/js/service-worker.js', { scope: '/' });
});
}
- Service worker itself is empty (1 line):
console.log('Successfully Installed Service Worker.');
- After running page load speed tests I get interesting results:
DOM Interactive DOM Complete Load Event End Number of page loads
no-service-worker 0.232 2.443 2.464 30
with-service-worker 0.343 2.484 2.502 30
What gives? How does an empty service worker slow down page load by whopping 120+ milliseconds?
Aucun commentaire:
Enregistrer un commentaire