Created
November 15, 2021 06:51
-
-
Save jikkujose/541c633aaa2ef9613b5bc6cc61533d6b to your computer and use it in GitHub Desktop.
Minimum PWA that satisfies Lighthouse tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<!-- | |
Steps to acheive perfect Lighthouse score | |
- [ ] Add service worker as separate file (sw.js) | |
- [ ] Uncomment registering of service worker (sw.js) | |
- [ ] Add `start_url` corresponding to where you host | |
- [ ] Add <link rel="canonical" href="link-to-show-up-in-search"/> | |
--> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width"> | |
<meta name="description" content="Single page PWA template that scores 100% on Lighhouse!"> | |
<meta name="theme-color" content="#000"> | |
<script type="application/ld+json"> | |
{ | |
"@context": "http://schema.org", | |
"@type": "WebApplication", | |
"name": "PWA", | |
"url": "https://jikkujose.in/pwa-starter/default", | |
"description": "Progressive Web Application", | |
"applicationCategory": "Utility", | |
"genre": "Web Development", | |
"aggregateRating": { | |
"@type": "AggregateRating", | |
"ratingValue": "5", | |
"ratingCount": "23" | |
}, | |
"offers": { | |
"@type": "Offer", | |
"price": "0", | |
"priceCurrency": "USD" | |
}, | |
"about": { | |
"@type": "Thing", | |
"description": "Progressive Web Application" | |
}, | |
"browserRequirements": "Requires JavaScript. Requires HTML5.", | |
"softwareVersion": "0.1", | |
"softwareHelp": { | |
"@type": "CreativeWork", | |
"url": "https://jikkujose.in/pwa-starter/default" | |
}, | |
"operatingSystem": "All" | |
} | |
</script> | |
<script> | |
if('serviceWorker' in navigator) { | |
//navigator.serviceWorker.register("./sw.js"); | |
}; | |
</script> | |
<title>PWA</title> | |
<link tag="link" rel="manifest" href="https://jikkujose.in/pwa-starter/default/manifest.json"> | |
<link tag="link" rel="icon" type="image/png" sizes="16x16" href="https://jikkujose.in/pwa-starter/default/images/icons/16x16.png"> | |
<link tag="link" rel="icon" type="image/png" sizes="32x32" href="https://jikkujose.in/pwa-starter/default/images/icons/32x32.png"> | |
<link tag="link" rel="icon" type="image/png" sizes="120x120" href="https://jikkujose.in/pwa-starter/default/images/icons/120x120.png"> | |
<link tag="link" rel="icon" type="image/png" sizes="150x150" href="https://jikkujose.in/pwa-starter/default/images/icons/150x150.png"> | |
<link tag="link" rel="apple-touch-icon" type="image/png" sizes="180x180" href="https://jikkujose.in/pwa-starter/default/images/icons/180x180.png"> | |
<link tag="link" rel="icon" type="image/png" sizes="192x192" href="https://jikkujose.in/pwa-starter/default/images/icons/192x192.png"> | |
<link tag="link" rel="icon" type="image/png" sizes="512x512" href="https://jikkujose.in/pwa-starter/default/images/icons/512x512.png"> | |
<link tag="link" rel="mask-icon" href="https://jikkujose.in/pwa-starter/default/images/icons/vector.svg" color="#000"> | |
<meta tag="meta" property="og:title" content="PWA"> | |
<meta tag="meta" property="og:site_name" content="PWA"> | |
<meta tag="meta" property="og:url" content="https://jikkujose.in/pwa-starter/default"> | |
<meta tag="meta" property="og:description" content="Progressive Web App"> | |
<meta tag="meta" property="og:type" content="product"> | |
<meta tag="meta" property="og:image" content="https://jikkujose.in/pwa-starter/default/images/social_preview.png"> | |
</head> | |
<body> | |
Default PWA Template | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.addEventListener("install", function(event) { | |
event.waitUntil( | |
caches.open("sw-cache").then(function(cache) { | |
return cache.addAll(["index.html"]) | |
}) | |
) | |
}) | |
self.addEventListener("fetch", function(event) { | |
event.respondWith( | |
caches.match(event.request).then(function(response) { | |
return response || fetch(event.request) | |
}) | |
) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment