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

Commit

Permalink
Unregister service worker.
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Aug 10, 2019
1 parent bead065 commit 2afc60b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/node_modules/
/source/assets/js/vendor/
/source/assets/js/google-analytics.js
/source/assets/js/sw.js
4 changes: 1 addition & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ module.exports = function(grunt) {
'<%= dirs.src %>/assets/js/detect-os.js',
'<%= dirs.src %>/assets/js/img-defer.js',
'<%= dirs.src %>/assets/js/no-js-class.js',
'<%= dirs.src %>/assets/js/pwa.js',
'<%= dirs.src %>/assets/js/google-analytics.js'
],
dest: '<%= dirs.dest %>/assets/js/pack.js'
Expand Down Expand Up @@ -145,8 +144,7 @@ module.exports = function(grunt) {
minify: {
files: {
'<%= concat.js.dest %>': '<%= concat.js.dest %>',
'<%= concat.jqueryJS.dest %>': '<%= concat.jqueryJS.dest %>',
'<%= concat.sw.dest %>': '<%= concat.sw.dest %>'
'<%= concat.jqueryJS.dest %>': '<%= concat.jqueryJS.dest %>'
}
}
},
Expand Down
15 changes: 0 additions & 15 deletions source/assets/js/pwa.js

This file was deleted.

24 changes: 23 additions & 1 deletion source/assets/js/sw.js
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
// empty for now
(function() {
'use strict';

if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.getRegistrations().then(function(registrations) {
for (var registration of registrations) {
registration.unregister()
.then(function() {
return self.clients.matchAll();
})
.then(function(clients) {
clients.forEach(function(client) {
if (client.url && 'navigate' in client) {
client.navigate(client.url);
}
});
});
}
});
});
}
})();

0 comments on commit 2afc60b

Please sign in to comment.