GithubHelp home page GithubHelp logo

dimvai / pwa Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 32 KB

PWA with code as minimal as possible, as regards manifest + service worker, but with jQuery + Bootstrap + custom CSS.

License: GNU General Public License v3.0

CSS 1.43% HTML 25.53% JavaScript 73.03%

pwa's Introduction

Installable PWA with code as minimal as possible, as regards manifest & service worker, but with jQuery & Bootstrap & custom CSS. You can just follow the instructions, copy the files, not change anything and you will have a PWA!

What to do specifically, in order:

  1. Set your app's icon file, logo.png of size 512x512. Also include your favicon.ico.
  2. Add the manifest.json (change the properties appropriately).
  3. Add the pwa.js and the service-worker.js files (optionally change their content, but you don't have to).
  4. In your index.html add the references to the above things. In the head section set (change the colors/paths):
<meta name="theme-color" content="#3f48cc">
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<link rel="manifest" href="manifest.json">      

<script defer src="pwa.js"></script>

Note that pwa.js calls the service-worker.js, so you do not call service-worker.js in your code. (Note: It is sufficient to import pwa.js only on your main entry point, and not call it again on any other (sub)pages if you're sure that all users will pass through that entry point at least once. That being said, there's no harm in importing pwa.js in multiple files.)

In this example web-app, I have put all "PWA" files in a separate subdirectory called pwa, so they do not ruin the file structure. Unfortunately, service-worker.js must be in the root folder, and it is very complex to do otherwise (needs server configuration...).

I have included, also, a non-minimal service worker file, in order to help you do more things with your service worker, like set what assets to precache, or change your cache stragegy. In this (non-minimal) case, I have included more comments and have set:

  • the EXTERNAL resources to "Stale while revalidate" (it can be dangerous for external resources to "cache first"...)
  • the never-changed LOCAL resources (in my case bootstrap/jquery files) to "Cache first" and
  • the changing LOCAL resources to "Network first".

Enjoy!

pwa's People

Contributors

dimvai avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.