Skip to content

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

@wbinnssmith

Description

@wbinnssmith

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions