{"id":179,"date":"2023-04-26T13:11:17","date_gmt":"2023-04-26T13:11:17","guid":{"rendered":"https:\/\/manishshrivastava.com\/blog\/?p=179"},"modified":"2024-10-22T22:44:39","modified_gmt":"2024-10-22T22:44:39","slug":"pwa-enabled-website","status":"publish","type":"post","link":"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/","title":{"rendered":"PWA enabled website"},"content":{"rendered":"\n<ol>\n<li>Create your website code.<\/li>\n\n\n\n<li>Create <em>manifest.json<\/em> in the home directory with below code.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">{\n  \"name\": \"My One Page PWA\",\n  \"short_name\": \"PWA\",\n  \"description\": \"A simple one-page PWA\",\n  \"start_url\": \"\/index.html\",\n  \"display\": \"standalone\",\n  \"background_color\": \"#ffffff\",\n  \"theme_color\": \"#000000\",\n  \"icons\": [\n    {\n      \"src\": \"icons\/icon-192x192.png\",\n      \"sizes\": \"192x192\",\n      \"type\": \"image\/png\"\n    },\n    {\n      \"src\": \"icons\/icon-512x512.png\",\n      \"sizes\": \"512x512\",\n      \"type\": \"image\/png\"\n    }\n  ]\n}\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>3. Link manifest.josn in your project index file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">&lt;link rel=\"manifest\" href=\"\/manifest.json\"&gt;<\/code><\/pre>\n\n\n\n<p>4. Create a <code>service-worker.js<\/code> file.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">self.addEventListener('install', (event) =&gt; {\n  event.waitUntil(\n    caches.open('my-cache').then((cache) =&gt; {\n      return cache.addAll([\n        '\/',\n        '\/index.html',\n        '\/stylesheet.css',\n        '\/app.js',\n        '\/icons\/img-192x192.png',\n        '\/icons\/img-512x512.png'\n      ]);\n    })\n  );\n});\n\nself.addEventListener('fetch', (event) =&gt; {\n  event.respondWith(\n    caches.match(event.request).then((response) =&gt; {\n      return response || fetch(event.request);\n    })\n  );\n});\n<\/code><\/pre>\n\n\n\n<p>5. Add the Register the service worker code to your main JavaScript file ( i.e. app.js)<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">if ('serviceWorker' in navigator) {\n  window.addEventListener('load', () =&gt; {\n    navigator.serviceWorker.register('\/service-worker.js')\n      .then((registration) =&gt; {\n        console.log('Service worker registered:', registration);\n      })\n      .catch((error) =&gt; {\n        console.error('Service worker registration failed:', error);\n      });\n  });\n}<\/code><\/pre>\n\n\n\n<p>6. Host your website in <strong>HTTPS<\/strong><\/p>\n\n\n\n<p>7. Test your website via Chrome&#8217;s Lighthouse or the Application panel in Chrome DevTools.<\/p>\n\n\n\n<p>Cheers!<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>3. Link manifest.josn in your project index file. 4. Create a service-worker.js file. 5. Add the Register the service worker code to your main JavaScript file ( i.e. app.js) 6. Host your website in HTTPS 7. Test your website via Chrome&#8217;s Lighthouse or the Application panel in Chrome DevTools. Cheers!<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[31,23],"tags":[36,35,43,32],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PWA enabled website - Manish Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PWA enabled website - Manish Blog\" \/>\n<meta property=\"og:description\" content=\"3. Link manifest.josn in your project index file. 4. Create a service-worker.js file. 5. Add the Register the service worker code to your main JavaScript file ( i.e. app.js) 6. Host your website in HTTPS 7. Test your website via Chrome&#8217;s Lighthouse or the Application panel in Chrome DevTools. Cheers!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/\" \/>\n<meta property=\"og:site_name\" content=\"Manish Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-04-26T13:11:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-22T22:44:39+00:00\" \/>\n<meta name=\"author\" content=\"manishshrivastava\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"manishshrivastava\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/\"},\"author\":{\"name\":\"manishshrivastava\",\"@id\":\"https:\/\/manishshrivastava.com\/blog\/#\/schema\/person\/e4d02d0fe4a05267401de130fac850f0\"},\"headline\":\"PWA enabled website\",\"datePublished\":\"2023-04-26T13:11:17+00:00\",\"dateModified\":\"2024-10-22T22:44:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/\"},\"wordCount\":63,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/manishshrivastava.com\/blog\/#\/schema\/person\/19d0df1c38b86606412b5c821e67e67e\"},\"keywords\":[\"coding\",\"logic\",\"pwa\",\"tips and tricks\"],\"articleSection\":[\"concept\",\"Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/\",\"url\":\"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/\",\"name\":\"PWA enabled website - Manish Blog\",\"isPartOf\":{\"@id\":\"https:\/\/manishshrivastava.com\/blog\/#website\"},\"datePublished\":\"2023-04-26T13:11:17+00:00\",\"dateModified\":\"2024-10-22T22:44:39+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/manishshrivastava.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"concept\",\"item\":\"https:\/\/manishshrivastava.com\/blog\/category\/concept\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PWA enabled website\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/manishshrivastava.com\/blog\/#website\",\"url\":\"https:\/\/manishshrivastava.com\/blog\/\",\"name\":\"Manish Blog\",\"description\":\"Rubyist, Realist, Pragmatist, and Believer\",\"publisher\":{\"@id\":\"https:\/\/manishshrivastava.com\/blog\/#\/schema\/person\/19d0df1c38b86606412b5c821e67e67e\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/manishshrivastava.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/manishshrivastava.com\/blog\/#\/schema\/person\/19d0df1c38b86606412b5c821e67e67e\",\"name\":\"manish shrivastava\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/manishshrivastava.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8d35275f95d1cd3202c89c1693336453?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8d35275f95d1cd3202c89c1693336453?s=96&d=mm&r=g\",\"caption\":\"manish shrivastava\"},\"logo\":{\"@id\":\"https:\/\/manishshrivastava.com\/blog\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/99interview.com\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/manishshrivastava.com\/blog\/#\/schema\/person\/e4d02d0fe4a05267401de130fac850f0\",\"name\":\"manishshrivastava\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/manishshrivastava.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ba8ddd15351cbf6b58b3d8e16ce94b3b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ba8ddd15351cbf6b58b3d8e16ce94b3b?s=96&d=mm&r=g\",\"caption\":\"manishshrivastava\"},\"description\":\"Holds 15+ years of experience as a Software Development Expert. His vision is to share knowledge related to How Software can add value to anyone's life. Manish is a Software Developer and Open source contributor. He is an experienced developer with 15+ years of experience in creating awesome web and app projects based on specific requirements using Ruby, React, and sometimes python. He says, He is a Rubyist, Realist, Pragmatist, and Believer.\",\"sameAs\":[\"https:\/\/manishshrivastava.com\/blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PWA enabled website - Manish Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/","og_locale":"en_US","og_type":"article","og_title":"PWA enabled website - Manish Blog","og_description":"3. Link manifest.josn in your project index file. 4. Create a service-worker.js file. 5. Add the Register the service worker code to your main JavaScript file ( i.e. app.js) 6. Host your website in HTTPS 7. Test your website via Chrome&#8217;s Lighthouse or the Application panel in Chrome DevTools. Cheers!","og_url":"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/","og_site_name":"Manish Blog","article_published_time":"2023-04-26T13:11:17+00:00","article_modified_time":"2024-10-22T22:44:39+00:00","author":"manishshrivastava","twitter_card":"summary_large_image","twitter_misc":{"Written by":"manishshrivastava","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/#article","isPartOf":{"@id":"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/"},"author":{"name":"manishshrivastava","@id":"https:\/\/manishshrivastava.com\/blog\/#\/schema\/person\/e4d02d0fe4a05267401de130fac850f0"},"headline":"PWA enabled website","datePublished":"2023-04-26T13:11:17+00:00","dateModified":"2024-10-22T22:44:39+00:00","mainEntityOfPage":{"@id":"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/"},"wordCount":63,"commentCount":0,"publisher":{"@id":"https:\/\/manishshrivastava.com\/blog\/#\/schema\/person\/19d0df1c38b86606412b5c821e67e67e"},"keywords":["coding","logic","pwa","tips and tricks"],"articleSection":["concept","Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/","url":"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/","name":"PWA enabled website - Manish Blog","isPartOf":{"@id":"https:\/\/manishshrivastava.com\/blog\/#website"},"datePublished":"2023-04-26T13:11:17+00:00","dateModified":"2024-10-22T22:44:39+00:00","breadcrumb":{"@id":"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/manishshrivastava.com\/blog\/pwa-enabled-website\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/manishshrivastava.com\/blog\/"},{"@type":"ListItem","position":2,"name":"concept","item":"https:\/\/manishshrivastava.com\/blog\/category\/concept\/"},{"@type":"ListItem","position":3,"name":"PWA enabled website"}]},{"@type":"WebSite","@id":"https:\/\/manishshrivastava.com\/blog\/#website","url":"https:\/\/manishshrivastava.com\/blog\/","name":"Manish Blog","description":"Rubyist, Realist, Pragmatist, and Believer","publisher":{"@id":"https:\/\/manishshrivastava.com\/blog\/#\/schema\/person\/19d0df1c38b86606412b5c821e67e67e"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/manishshrivastava.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/manishshrivastava.com\/blog\/#\/schema\/person\/19d0df1c38b86606412b5c821e67e67e","name":"manish shrivastava","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/manishshrivastava.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8d35275f95d1cd3202c89c1693336453?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8d35275f95d1cd3202c89c1693336453?s=96&d=mm&r=g","caption":"manish shrivastava"},"logo":{"@id":"https:\/\/manishshrivastava.com\/blog\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/99interview.com"]},{"@type":"Person","@id":"https:\/\/manishshrivastava.com\/blog\/#\/schema\/person\/e4d02d0fe4a05267401de130fac850f0","name":"manishshrivastava","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/manishshrivastava.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ba8ddd15351cbf6b58b3d8e16ce94b3b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ba8ddd15351cbf6b58b3d8e16ce94b3b?s=96&d=mm&r=g","caption":"manishshrivastava"},"description":"Holds 15+ years of experience as a Software Development Expert. His vision is to share knowledge related to How Software can add value to anyone's life. Manish is a Software Developer and Open source contributor. He is an experienced developer with 15+ years of experience in creating awesome web and app projects based on specific requirements using Ruby, React, and sometimes python. He says, He is a Rubyist, Realist, Pragmatist, and Believer.","sameAs":["https:\/\/manishshrivastava.com\/blog"]}]}},"_links":{"self":[{"href":"https:\/\/manishshrivastava.com\/blog\/wp-json\/wp\/v2\/posts\/179"}],"collection":[{"href":"https:\/\/manishshrivastava.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/manishshrivastava.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/manishshrivastava.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/manishshrivastava.com\/blog\/wp-json\/wp\/v2\/comments?post=179"}],"version-history":[{"count":2,"href":"https:\/\/manishshrivastava.com\/blog\/wp-json\/wp\/v2\/posts\/179\/revisions"}],"predecessor-version":[{"id":211,"href":"https:\/\/manishshrivastava.com\/blog\/wp-json\/wp\/v2\/posts\/179\/revisions\/211"}],"wp:attachment":[{"href":"https:\/\/manishshrivastava.com\/blog\/wp-json\/wp\/v2\/media?parent=179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/manishshrivastava.com\/blog\/wp-json\/wp\/v2\/categories?post=179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/manishshrivastava.com\/blog\/wp-json\/wp\/v2\/tags?post=179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}