perf: fonts are already base64 text, no need to re-base64 a second time #362
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Goal?
Reduce the size of the Offline HTML file.
Fixes?
When we embed the fonts in the Offline HTML, we base64 encode them twice: once from the three
.woff2
files intofonts.b64.css
, and a second time putting that into the<link rel="stylesheet" href="...">
line in the.html
file.This is wasteful because the
.css
file is already plain text, having had its binary components b64 encoded already.Instead, this PR proposes to wrap the verbatim contents of the
.css
file in a<style>
element, which has the same effects.The results are nice: a trivial readalong goes from 850kb down to 680kb, a saving of roughly 170kb in each RA we download as Offline HTML.
Feedback sought?
testing to make sure this doesn't break anything!
Priority?
low
Tests added?
no yet, no.
How to test?
These are tests I have also done:
Create a readalong or edit an existing one, download it as single file HTML, and see it is smaller but still works correctly, even if you network cable is unplugged.
Upload it back on the currently deployed app, and see you can keep editing, and downloading it from this version or the deployed one, differs in the size of the .html file but not in functionality.
Confidence?
Medium-high
Version change?
no, because while the .html file is different, it is still fully backwards compatible.