Skip to content
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

Dynamic imports loaded as low-priority scripts when compiled #6980

Closed
wbinnssmith opened this issue Sep 23, 2021 · 0 comments · Fixed by #7061
Closed

Dynamic imports loaded as low-priority scripts when compiled #6980

wbinnssmith opened this issue Sep 23, 2021 · 0 comments · Fixed by #7061

Comments

@wbinnssmith
Copy link
Contributor

wbinnssmith commented Sep 23, 2021

Native dynamic imports (e.g. import('./foo')) are typically loaded by browsers with high priority. However, when targeting browsers without native or polyfillable support, Parcel inserts <script async> tags into the head, which are loaded with low priority. See https://addyosmani.com/blog/script-priorities/.

With that said, we should probably still include the async attribuite on these scripts as their execution order isn't important. One workaround to boost priority of async scripts is to also insert a <link rel="preload" as="script"> with an href with the same value as the script's src.

We should consider adding these link tags as well when loading js targeted at these environments.

Related: #6981

gorakong pushed a commit that referenced this issue Nov 3, 2022
* upstream/v2:
  Upgrade Flow to 0.174.1 (#7849)
  v2.4.0
  v2.4.0 changelog
  Bump Parcel CSS
  Dynamic imports priority fix closes #6980 (#7061)
  fix(transformers): errors.map is not a function (#7672)
  Make NodeResolver check realpath before resolving with `source` entry (#7846)
  docs: fix wrong location documents (#7689)
  Fix: escape double quote of url value in CSS `url()` (#7718)
  Update @parcel/css and add diagnostic for url dependencies in custom properties (#7845)
  Use relative path for bundle labels in bundle analysis (#7737)
  Allow use react-jsx transform in React 16.14.0 (#7728)
  Move to @parcel/css by default (#7821)
  Feature: pick PORT number also from .env file (#7819)
  Enable parsing static initialization blocks (#7839)
  Bump swc and prevent pure comment removal (#7833)
  Bump swc (#7777)
  Human readable file size in bundle analyzer report (#7766)
  Improve emoji support detection (#7775)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants