Request only a single JS bundle from index.ts
#931
Merged
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.
We introduce a new
indexDelayed.ts
file that bundles all the imports that are used in theindex.ts
file. They are not imported directly there, because we want to keep the size of theindex.html
as small as possible, so it can focus on requesting the WASM file as soon as possible. This should result in theindexDelayed.ts
bundle containing basically all the JS. This JS bundle and the WASM file should then be requested in parallel. While it would be possible to request these all individually over in theindex.ts
, browsers don't actually like doing too many requests in parallel and it turns out that big JavaScript files actually compress better than having many small ones. The WASM file also is pretty big, so ideally we are not bottlenecked by the large JS file. If necessary, we could do some more bundle splitting for stuff that isn't used until much later, like the Markdown library.