curiousdannii / parchment

The Interactive Fiction web app
https://iplayif.com
MIT License
421 stars 60 forks source link

Build Parchment as a single HTML file, suitable for downloading #114

Closed dfabulich closed 2 years ago

dfabulich commented 2 years ago

Today, Parchment builds as an HTML file with <script> tags linking to various required scripts, and a <link rel=stylesheet> for its CSS.

If Parchment built a single all-in-one HTML file with all required scripts embedded in it, users would be able to download the HTML file and double-click on it to run it offline, without requiring a complex service worker.

It could even be an optional, secondary download, e.g. iplayif.com/parchment.html and then the index.html home page could have a link like this: <a download href=parchment.html>Download Parchment to use it offline</a>

curiousdannii commented 2 years ago

Should be possible, but it's gonna be a big file. With all the engines and all fonts I guess it would be around 10MB. Probably better to zip it up and offer that for download.

curiousdannii commented 2 years ago

Turned out to be quite easy! And only 6MB... It's in the testing branch, and also deployed to https://curiousdannii.github.io/parchment-testing/dist/single-file/parchment.html https://curiousdannii.github.io/parchment-testing/dist/single-file/parchment-single-file.zip

The Iosevka fonts are almost 3MB before being base64 encoded. Do you think it's worth including them in the single file mode? I think it's not.

Edit: realised there's no point to including Git or Glulxe when they can't even be chosen instead of Quixe. So that brings the filesize down a bit.

curiousdannii commented 2 years ago

So one option would be to embed only the base font, and rely on the browser faking italics and bold. Here's how that would look.

Real italics and bold: Real italics and bold

Faked italics and bold: Screenshot with faked italics and bold

Edit: That's what I've done. Regular is embedded, and the browser can fake the others.