marijnh / Eloquent-JavaScript

The sources for the Eloquent JavaScript book
https://eloquentjavascript.net
3.01k stars 795 forks source link

Add a web app manifest #378

Closed marijnh closed 5 years ago

marijnh commented 6 years ago

As in https://w3c.github.io/manifest/# . This would be a good fit for that since it can be useful to have offline and doesn't need any dynamic server component to begin with.

marijnh commented 6 years ago

This appears to be pretty simple to do, but I'm not sure it'll help a lot when it comes to reading offline—this format doesn't appear to allow you to specify a list of files to pre-cache. Am I missing something? Here's the manifest I've been experimenting with:

{
  "lang": "en",
  "dir": "ltr",
  "name": "Eloquent JavaScript",
  "description": "A book about JavaScript, programming, and the wonders of the digital",
  "short_name": "EJS",
  "icons": [{
    "src": "img/favicon.ico",
    "sizes": "16x16"
  }, {
    "src": "img/icon64.png",
    "sizes": "32x32 48x48 64x64"
  }, {
    "src": "img/icon128.png",
    "sizes": "72x72 96x96 128x128"
  }],
  "scope": "/",
  "start_url": "index.html",
  "theme_color": "#fed61f",
  "background_color": "white"
}
igalic commented 6 years ago

i did a recursive wget of eloquentjs.net to my laptop and added your manifest, plus a <link> to the index.html. then presented the whole thing via http (port 80) to my phone.

it did not offer an [add this to your homescreen] button.


from what i gather from the spec, you might also need to register a service-worker for the matching scope. this can either happen in the manifest, or in a surounding javascript… however… what i'm not clear about (yet) is whether you need to provide your own code

i'll try that after lunch.

marijnh commented 6 years ago

Thanks for looking into this. From scanning over the spec, offline use doesn't seem to be an important use case of this feature (but if it can be abused to make that possible, that would be great).

marijnh commented 6 years ago

(I am not really interested in heavyweight solutions or things that eat bandwidth to pre-cache stuff by default.)