Skip to content
This repository was archived by the owner on Sep 15, 2020. It is now read-only.

Commit 2afc60b

Browse files
committed
Unregister service worker.
1 parent bead065 commit 2afc60b

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/node_modules/
44
/source/assets/js/vendor/
55
/source/assets/js/google-analytics.js
6+
/source/assets/js/sw.js

Gruntfile.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ module.exports = function(grunt) {
7979
'<%= dirs.src %>/assets/js/detect-os.js',
8080
'<%= dirs.src %>/assets/js/img-defer.js',
8181
'<%= dirs.src %>/assets/js/no-js-class.js',
82-
'<%= dirs.src %>/assets/js/pwa.js',
8382
'<%= dirs.src %>/assets/js/google-analytics.js'
8483
],
8584
dest: '<%= dirs.dest %>/assets/js/pack.js'
@@ -145,8 +144,7 @@ module.exports = function(grunt) {
145144
minify: {
146145
files: {
147146
'<%= concat.js.dest %>': '<%= concat.js.dest %>',
148-
'<%= concat.jqueryJS.dest %>': '<%= concat.jqueryJS.dest %>',
149-
'<%= concat.sw.dest %>': '<%= concat.sw.dest %>'
147+
'<%= concat.jqueryJS.dest %>': '<%= concat.jqueryJS.dest %>'
150148
}
151149
}
152150
},

source/assets/js/pwa.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

source/assets/js/sw.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
1-
// empty for now
1+
(function() {
2+
'use strict';
3+
4+
if ('serviceWorker' in navigator) {
5+
window.addEventListener('load', function() {
6+
navigator.serviceWorker.getRegistrations().then(function(registrations) {
7+
for (var registration of registrations) {
8+
registration.unregister()
9+
.then(function() {
10+
return self.clients.matchAll();
11+
})
12+
.then(function(clients) {
13+
clients.forEach(function(client) {
14+
if (client.url && 'navigate' in client) {
15+
client.navigate(client.url);
16+
}
17+
});
18+
});
19+
}
20+
});
21+
});
22+
}
23+
})();

0 commit comments

Comments
 (0)