service-worker

This commit is contained in:
Said Tahsin Dane 2015-03-14 00:47:13 +02:00
parent 663186c708
commit 0a8fbff321
3 changed files with 21 additions and 3 deletions

View file

@ -51,4 +51,17 @@
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]--> <![endif]-->
<script>
window.addEventListener('load', function() {
navigator.serviceWorker.register('{{ site.baseurl }}/service-worker.js', {scope: '{{ site.baseurl }}/'})
.then(function(r) {
console.log('registered service worker');
})
.catch(function(whut) {
console.error('uh oh... ');
console.error(whut);
});
});
</script>
</head> </head>

View file

@ -8,13 +8,16 @@ layout: null
{ {
"src": "{{ site.baseurl }}/img/favicons/favicon-96x96.png", "src": "{{ site.baseurl }}/img/favicons/favicon-96x96.png",
"sizes": "96x96", "sizes": "96x96",
"type": "image/png" "type": "image/png",
"density": "2.0"
}, },
{ {
"src": "{{ site.baseurl }}/img/favicons/apple-touch-icon-144x144.png", "src": "{{ site.baseurl }}/img/favicons/apple-touch-icon-144x144.png",
"sizes": "144x144", "sizes": "144x144",
"type": "image/png" "type": "image/png",
"density": "3.0"
} }
], ],
"display": "standalone" "display": "standalone",
"start_url": "{{ site.baseurl }}/index.html"
} }

2
service-worker.js Normal file
View file

@ -0,0 +1,2 @@
// Empty service worker for App Install banners to work.
// Can be implemented to have offline and sync support.