(window.webpackJsonp=window.webpackJsonp||[]).push([[1805],{2213:function(t,s,a){"use strict";a.r(s);var n=a(31),e=Object(n.a)({},(function(){var t=this,s=t.$createElement,a=t._self._c||s;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"workers"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#workers"}},[t._v("#")]),t._v(" Workers")]),t._v(" "),a("h2",{attrs:{id:"a-simple-service-worker"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#a-simple-service-worker"}},[t._v("#")]),t._v(" A simple service worker")]),t._v(" "),a("h3",{attrs:{id:"main-js"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#main-js"}},[t._v("#")]),t._v(" main.js")]),t._v(" "),a("blockquote"),t._v(" "),a("p",[t._v("A service worker is an event-driven worker registered against an origin and a path. It takes the form of a JavaScript file that can control the web page/site it is associated with, intercepting and modifying navigation and resource requests, and caching resources in a very granular fashion to give you complete control over how your app behaves in certain situations (the most obvious one being when the network is not available.)")]),t._v(" "),a("p",[t._v("Source: "),a("a",{attrs:{href:"https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API",target:"_blank",rel:"noopener noreferrer"}},[t._v("MDN"),a("OutboundLink")],1)]),t._v(" "),a("h3",{attrs:{id:"few-things"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#few-things"}},[t._v("#")]),t._v(" Few Things:")]),t._v(" "),a("ol",[a("li",[t._v("It's a JavaScript Worker, so it can't access the DOM directly")]),t._v(" "),a("li",[t._v("It's a programmable network proxy")]),t._v(" "),a("li",[t._v("It will be terminated when not in use and restarted when it's next needed")]),t._v(" "),a("li",[t._v("A service worker has a lifecycle which is completely separate from your web page")]),t._v(" "),a("li",[t._v("HTTPS is Needed")])]),t._v(" "),a("p",[t._v("This code that will be executed in the Document context, (or) this JavaScript will be included in your page via a "),a("code",[t._v("