systemjs / systemjs

Dynamic ES module loader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support fetchPriority with external import maps

erikt9 opened this issue · comments

Description of Proposed Feature

When using an external import map, it seems to be a common use case where loading the map is blocking the loading of multiple modules on the page. It would be nice if we can boost loading priority of the external import map using the fetchPriority property of <script>tags.

https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement

fetchPriority on scripts is supported in both Chrome and Safari now (and browsing through Firefox it looks like they are making steady progress). Support for the similar priority property of fetch calls is identical. Would be nice if we could leverage this standard for a little boost in modern browsers.

This also helps alleviate the problem that using <link rel="preload" as="fetch" src="import_map.json"> is difficult to get working in a cross browser fashion (https://stackoverflow.com/questions/52635660/can-link-rel-preload-be-made-to-work-with-fetch) and even the cross browser method wouldn't work with SystemJS without making a completely custom fetch method to pass the correct options.

Invoke like:
<script type="system-js-importmap" src="https://import_map_url" fetchpriority="high" />

In what way would you use it?

Increase priority of import map loading (could also lower if appropriate for your app).