New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speculatively parsing with import map if there's a dynmic import before, #281
Comments
It's really up to the implementing browser? Like all speculative parsing, that's an optimization you can choose to perform, which may be wasted or may be useful. Although in the case you list, I'm not sure what you mean by "preload the import map", since it is inline. |
I am trying to preload the inline import map script tag as well, as the speculative parser will try to preload the module script tag. However, if the parser preloads the import map tag, but it won't know the dymanic import call from the javascript, and 'accepts' the import map tag instead. I'd like to point out that with import map tag, preloading and non-preloading module scripts (for speculative parsing) could possibly have different bahaviors. |
Yep, that's what that section is about! Like |
It probably still makes sense to incorporate import maps when available into the preloading, assuming they will apply, unless there is an obvious statically detectable violation like a module script before an import map tag. |
Per https://github.com/WICG/import-maps#interaction-with-speculative-parsingfetching,
I'd like to ask whether we should preload the import map or not.
If there's a dynamic import call before the import map tag,
<script> import("foo.js"); </script> <script type="importmap">...</script> <script type="module" src="bar.mjs"></script>According to the spec, the dynamic import call will set acquiring importmaps to false, so the following import map shouldn't be accepted, and if bar.mjs uses the specifier from the import map, that should also fail.
It looks fine if the parser doesn't preload the importmap script tag and module script tag, but if it does preloading, the fetching for bar.mjs seems wasted.
The text was updated successfully, but these errors were encountered: