Currently in the spec, early hints work only for preload (and soon for preconnect).
In Chromium source code (as I understand it) and in WPT, modulepreload is also supported, but it's treated like a preload in the sense that it doesn't start loading module dependencies. It still uses the special fetching defaults/parameters of modulepreload like having script as the default for as.
I see how it's problematic to start creating actual script objects before the document is initialized, but it also changes the semantics of modulepreload when it's an early hint, which might be confusing - e.g. if the developer doesn't add an actual equivalent <link rel=modulepreload> to the document, the dependencies will only be fetched when the module is imported in practice.
I suggest the following strategy in the spec (and implementation):
- Keep the existing Chromium behavior when the early hint headers are processed
- Once the document is created, also preload the script graph immediately as if the document had a regular
modulepreload header.
Currently in the spec, early hints work only for
preload(and soon forpreconnect).In Chromium source code (as I understand it) and in WPT,
modulepreloadis also supported, but it's treated like apreloadin the sense that it doesn't start loading module dependencies. It still uses the special fetching defaults/parameters ofmodulepreloadlike havingscriptas the default foras.I see how it's problematic to start creating actual script objects before the document is initialized, but it also changes the semantics of
modulepreloadwhen it's an early hint, which might be confusing - e.g. if the developer doesn't add an actual equivalent<link rel=modulepreload>to the document, the dependencies will only be fetched when the module is imported in practice.I suggest the following strategy in the spec (and implementation):
modulepreloadheader.