14
14
15
15
Import from [ unpkg.com] ( https://unpkg.com/ ) :
16
16
17
- - UMD: https://unpkg.com/service-worker-updatefound-refresh-dialog/service-worker-updatefound-refresh-dialog.umd.js
17
+ - UMD: https://unpkg.com/service-worker-updatefound-refresh-dialog/dist/ service-worker-updatefound-refresh-dialog.umd.js
18
18
- mjs: https://unpkg.com/service-worker-updatefound-refresh-dialog?module
19
19
20
20
## Usage
@@ -34,7 +34,7 @@ You should inject refresh dialog script to two place.
34
34
<title >Example</title >
35
35
</head >
36
36
<body >
37
- <script src =" https://unpkg.com/service-worker-updatefound-refresh-dialog/service-worker-updatefound-refresh-dialog.umd.js" ></script >
37
+ <script src =" https://unpkg.com/service-worker-updatefound-refresh-dialog/dist/ service-worker-updatefound-refresh-dialog.umd.js" ></script >
38
38
<script >
39
39
window .addEventListener (' load' , function () {
40
40
navigator .serviceWorker .register (' /sw.js' )
@@ -50,18 +50,10 @@ You should inject refresh dialog script to two place.
50
50
** Add to your service worker** (sw.js):
51
51
52
52
``` js
53
- self .addEventListener (" message" , event => {
54
- if (! event .data ) {
55
- return ;
56
- }
57
- if (event .data === " skipWaiting" ) {
58
- self .skipWaiting ();
59
- }
60
- });
53
+ // sw.js
54
+ importScripts (" https://unpkg.com/service-worker-updatefound-refresh-dialog/dist/service-worker-updatefound-refresh-dialog.umd.js" );
61
55
```
62
56
63
- -
64
-
65
57
### Options
66
58
67
59
- ` message ` : Custom message
@@ -123,14 +115,7 @@ Do you forget to inject a script to service worker like `sw.js`?
123
115
124
116
``` js
125
117
// sw.js
126
- self .addEventListener (" message" , event => {
127
- if (! event .data ) {
128
- return ;
129
- }
130
- if (event .data === " skipWaiting" ) {
131
- self .skipWaiting ();
132
- }
133
- });
118
+ importScripts (" https://unpkg.com/service-worker-updatefound-refresh-dialog/service-worker-updatefound-refresh-dialog.umd.js" );
134
119
```
135
120
136
121
### ` skipWaiting() ` integration
@@ -145,6 +130,7 @@ These method trigger `statechange` event of the service worker without asking th
145
130
``` diff
146
131
// workbox init setting
147
132
importScripts("https://storage.googleapis.com/workbox-cdn/releases/3.6.1/workbox-sw.js");
133
+ + importScripts("https://unpkg.com/service-worker-updatefound-refresh-dialog/service-worker-updatefound-refresh-dialog.umd.js")
148
134
149
135
workbox.core.setCacheNameDetails({ prefix: "website-v1" });
150
136
workbox.googleAnalytics.initialize();
0 commit comments