PWA optimizations (#274)
* feat: added service worker and pwa optimizations * fix: added newline at the end of Gemfile.lock to match main branch * fix: fixed newline at the end of Gemfile.lock to match main branch
This commit is contained in:
parent
1abc68efe5
commit
e8e5b61404
4 changed files with 33 additions and 5 deletions
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.css" />
|
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.css" />
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.js"></script>
|
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.js"></script>
|
||||||
|
<script type="text/javascript" src="{{ base_path }}/images/pwa.js"></script>
|
||||||
<script>
|
<script>
|
||||||
window.addEventListener("load", function(){
|
window.addEventListener("load", function(){
|
||||||
window.cookieconsent.initialise({
|
window.cookieconsent.initialise({
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
{
|
{
|
||||||
"name": "",
|
"name": "Wii Guide",
|
||||||
|
"short_name": "Wii Guide",
|
||||||
|
"description": "The complete guide to modding your Nintendo Wii.",
|
||||||
|
"start_url": "/",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "/android-chrome-192x192.png",
|
"src": "./android-chrome-192x192.png",
|
||||||
"sizes": "192x192",
|
"sizes": "192x192",
|
||||||
"type": "image/png"
|
"type": "image/png",
|
||||||
|
"purpose": "maskable"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "/android-chrome-512x512.png",
|
"src": "./android-chrome-512x512.png",
|
||||||
"sizes": "512x512",
|
"sizes": "512x512",
|
||||||
"type": "image/png"
|
"type": "image/png",
|
||||||
|
"purpose": "any"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"theme_color": "#ffffff",
|
"theme_color": "#ffffff",
|
||||||
|
|
11
images/pwa.js
Normal file
11
images/pwa.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
document.addEventListener('DOMContentLoaded', init, false);
|
||||||
|
function init() {
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
navigator.serviceWorker.register('/images/service-worker.js')
|
||||||
|
.then((reg) => {
|
||||||
|
// Service worker registration confirmed
|
||||||
|
}, (err) => {
|
||||||
|
// Service worker registration error
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
11
images/service-worker.js
Normal file
11
images/service-worker.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
self.addEventListener('install', function(event) {
|
||||||
|
// registering service worker...
|
||||||
|
})
|
||||||
|
|
||||||
|
self.addEventListener('fetch', function(event) {
|
||||||
|
// intercepting requests to check for the file or data in the cache
|
||||||
|
})
|
||||||
|
|
||||||
|
self.addEventListener('activate', function(event) {
|
||||||
|
// service worker activated!
|
||||||
|
})
|
Loading…
Reference in a new issue