chore(new-client): preload key requests #1829
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.
Currently when we run the Lighthouse performance test we can appreciate the following suggestion: "Preload key requests", and then the report shows a list with 6-7 assets that should have been pre-loaded with a
<link rel="preload />
tag.Lighthouse is correct, those assets are being loaded immediately after the parser evaluates the "shell" bundle, so it makes sense to have them as "preload" links in the
index.html
file. I thought that Vite would be able to do that automatically if instead of declaring our lazy components like this:we declared them like this:
The reason being that with the first declaration the bundler can't know when that component would be used (mounted). However, with the second declaration the bundler should IMO be able to figure out that the dynamic import is being requested during bootstrap time... So, I think that ideally Vite should handle those cases, that's why I've opened this issuse: vitejs/vite#2460 .
In the meanwhile, though, I've found a rollup plugin that we can use with Vite for now if we tweak it a bit... So, that's what this PR is about.