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:
Jeith 2022-07-15 09:49:36 -05:00 committed by GitHub
parent 1abc68efe5
commit e8e5b61404
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 5 deletions

View file

@ -29,6 +29,7 @@
<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 type="text/javascript" src="{{ base_path }}/images/pwa.js"></script>
<script>
window.addEventListener("load", function(){
window.cookieconsent.initialise({

View file

@ -1,15 +1,20 @@
{
"name": "",
"name": "Wii Guide",
"short_name": "Wii Guide",
"description": "The complete guide to modding your Nintendo Wii.",
"start_url": "/",
"icons": [
{
"src": "/android-chrome-192x192.png",
"src": "./android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/android-chrome-512x512.png",
"src": "./android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
"type": "image/png",
"purpose": "any"
}
],
"theme_color": "#ffffff",

11
images/pwa.js Normal file
View 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
View 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!
})