From the course: JavaScript: Service Workers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Defer service worker registration

Defer service worker registration - JavaScript Tutorial

From the course: JavaScript: Service Workers

Start my 1-month free trial

Defer service worker registration

- [Instructor] Let's talk a little bit about the performance of registering a service worker. Typically, we register a service worker as soon as JavaScript executes, so we have a code in our page that is just calling, navigate to our service worker, register. But on the first load, we need to remember that the window that is actually registering the service worker is not going to be controlled by that service worker. Now, I'm talking about the first load, so the first time you're accessing to that website, so you don't have a service worker activated in your computer, in that case, because there is no service worker, that window is uncontrolled. It's an uncontrolled client. So, there is no rush into installing a register that service worker. So in terms of priority, it's probably better to render the contents of the page, rather than downloading the service worker, executing the service worker, and downloading all the assets that the service worker will pre-cache, so because we can…

Contents