Skip to content

Enable using "modulepreload" instead of "preload" for module links #8438

@TxHawks

Description

@TxHawks

Feature request

@janicklas-ralph introduced the module/nomodule pattern in #7704, which allows modern browsers to load javascript through the use of es2015 modules, and therefore, more modern, less transpiled-down code based on the support vector of browsers supporting modules, while still offering more a fallback to less modern browsers.

However, the pull request still uses <link rel="preload" /> to preload the modules. As suggested in this Google Developers guide, and again today by Phill Walton using <link rel="modulepreload" /> would be more efficient, since it doesn't only download the script, but also starts processing and compiling it immediately - off the main thread.

One caveat though, is that modulepreload is only supported in chromium-based browsers.

Describe the solution you'd like

A configurable option to use modulepreload instead of preload for module files. Making this configurable allows optimizing for the bulk of an application's user-base. I guess keeping preload as the default makes sense for the time being.

Describe alternatives you've considered

Keeping preload as it is now, or alternatively, using modulepreload as default and making the tradeoff very clear in the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions