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.

Understand the scope

Understand the scope - JavaScript Tutorial

From the course: JavaScript: Service Workers

Start my 1-month free trial

Understand the scope

- [Instructor] We have already mentioned that every service worker has one scope. We know that the scope, it's basically a domain, a port number, and also a path, that can also be the root folder. So, the service worker will manage everything that happens, within that scope. So, for example, if the scope is https://linkedin.com, then here we can see several examples that will be managed by the service worker. So, linkedin.com, so the home page, will be managed by the service worker, the same as /about, or /assets/static/terms.pdf, or anything inside that domain. But if we are going to a different port, such as linkedin.com:1800, that's not managed by that service worker, because it's a different scope. The same happens if there is a subdomain, such as learning.linkedin.com. It's a completely different scope. If you define the scope as a subfolder of your domain, such as linkedin.com/pwa, then now, the homepage of linkedin.com or /about are not part of that scope. Only files or…

Contents