Skip to content

specifier: URL protocol for retrofitting specifiers in places designed for URLs #12163

Open

Description

@LeaVerou

We keep seeing efforts to extend specifiers to additional types of resources, for example Declarative adoptedStyleSheets for Sharing Styles In Declarative Shadow DOM which extends the concept of specifiers to refer to CSS stylesheets:

<style type="module" specifier="my-component-styles">...</style>

<my-element>
  <template shadowrootmode="open" shadowrootadoptedstylesheets="my-component-styles">
      <div>...component content...</div>
  </template>
<my-element>

Essentially, specifiers are an abstraction over URLs, and a quite useful one at that when multiple packages from different sources are coordinating. In some ways, they provide the benefits of a relative path, without having to figure out the right relative path.
Additionally, the motivation behind many of these efforts is the way the JS module graph circumvents excessive HTTP roundtripping.
Neither of these benefits are fundamentally tried to JS, and I suspect we will see more of these efforts over time.

However, while ESM import syntax was designed with specifiers in mind and syntactically disambiguates between the two, the vast majority of the platform was designed to be URL-first and cannot be retrofitted to accept specifiers. For example, this means that <link rel=stylesheet> or the CSS @import syntax would not be able to read these CSS specifiers, making something like CSS modules an ad hoc feature specifically for the benefit of web components. Even for JS, <script type="module" src> cannot accept specifiers. Yes, we can invent ad hoc syntax to enable specifiers to be used in every one of these cases (e.g. @import specifier(foo)), but given the places resources can be imported, that seems like a lot of (likely inconsistent) API surface.

A potential solution could be to fully embrace specifiers as a high-level abstraction over URLs and do something along the lines of:

  • A new specifier: URL protocol. Specifier URLs resolve to an actual URL before being fetched, but which URL they resolve to also depends on the request's Origin header (so that import map scopes function properly)
  • In certain contexts (such as ESM imports or this new shadowrootadoptedstylesheets attribute) the specifier: protocol is implied
  • HTTP caching would work differently; basically in a way that emulates the current behavior of the JS module cache.
  • This proposal is not concerned about how specifiers resolve at all, this is the subject of other technologies/proposals. This is about hooking in to the existing resolution mechanisms, whatever those are (import maps, HTTP headers, etc).

Obviously this is an early sketch/strawman and very handwavy, not a detailed, fleshed out proposal.

Architecturally, this has the advantage that it bridges the gap between specifiers and URLs. Rather than having two entirely separate primitives for linking to a resource, it makes specifiers the high-level primitive and URLs the low-level primitive that explains it, making the mental model around resource fetching more coherent and easier to explain.

In terms of use cases, it can be incredibly powerful: ultimately specifiers could be used anywhere a URL can, including images, videos, import map URLs (alias specifiers to other specifiers!), <iframe src>, SVG <use>, CSS url() etc. Though it doesn't have to ship to all of these at once (see below).

Implementation-wise, implementing this properly would be a big task. URLs are handled all over the place and it would likely break assumptions all over the codebase. However! What could work is prototyping it with ad hoc handling, but in a way that creates the illusion of general URL handling. E.g. instead of having an ad hoc CSS syntax like @import specifier(blah) which will be ad hoc forever, implement @import url("specifier:blah") but resolve to a URL as part of @import handling (based on the existing mechanisms to do so, e.g. import maps), then propagate a URL for any further handling. Then later down the line once more parts of the codebase have been handling specifier: URLs, explore refactoring to move it under general URL handling. That way, implementation effort would be the same as ad hoc syntax, but the author-facing API surface is the same everywhere. The downside is that for a while we'd be in the awkward middle ground where specifier: URLs work in some places but not others, but IMO swapping a permanent problem for a temporary one is a win.

I’ve run the above by @yoavweiss who agreed (Yoav please correct me I misrepresented anything!) and added:

OK, implementation-wise I think it can work if you define some SpecifierOrURL handling class and use it in a small number of places, expanding over time

Activity

  1. changed the title [-]`specifier:` URL protocol for using specifiers in web platform places that were not designed for them[/-] [+]`specifier:` URL protocol for retrofitting specifiers in places designed for URLs[/+] on Feb 14, 2026
  2. sorvell commented on Feb 21, 2026

    @sorvell

    I fully support this concept. The ability to map specifiers to URLs is incredibly useful, and it's a major platform flaw that this feature is currently restricted to module scripts.

    HTTP caching would work differently; basically in a way that emulates the current behavior of the JS module cache.

    One concern I have here is that, as I understand it, the module system doesn't cache the fetched resource, it caches the result of processing the fetched resource. This might be a mismatch here and/or require additional syntax to clarify the intent, at least in some cases. For example, assume here that an importmap exists for "foo": "./foo.css":

    @import url('./foo.css'); /* rule 0 */
    @import url('./foo.css'); /* rule 1 */
    @import url('speicifer:foo'); /* rule 2 */
    @import url('speicifer:foo'); /* rule 3 */

    In that sheet rule[0].styleSheet !== rule[1].styleSheet, and I believe that's not up for debate.

    But does rule[2].styleSheet === rule[3].styleSheet? If they act like JS modules, then the answer is yes. I very much want this to be the case. Is that the intention here?

  3. LeaVerou commented on Feb 21, 2026

    @LeaVerou
    MemberAuthor

    One concern I have here is that, as I understand it, the module system doesn't cache the fetched resource, it caches the result of processing the fetched resource. This might be a mismatch here and/or require additional syntax to clarify the intent, at least in some cases. For example, assume here that an importmap exists for "foo": "./foo.css":

    @import url('./foo.css'); /* rule 0 /
    @import url('./foo.css'); /
    rule 1 /
    @import url('speicifer:foo'); /
    rule 2 /
    @import url('speicifer:foo'); /
    rule 3 */
    In that sheet rule[0].styleSheet !== rule[1].styleSheet, and I believe that's not up for debate.

    But does rule[2].styleSheet === rule[3].styleSheet? If they act like JS modules, then the answer is yes. I very much want this to be the case. Is that the intention here?

    Yes, that is the intention here. The fact that it's not the case for URLs is unfortunate. Ideally, we'd want to solve this for URLs too, in a backwards compatible way. Basically, a behavior that URLs can opt-in to that does this, but specifier URLs have it by default. What would that look like? An HTTP header?

  4. sorvell commented on Feb 22, 2026

    @sorvell

    Related specifically to @import: w3c/csswg-drafts#8297. Also mentioned in that issue is @jakearchibald's proposal for fetch-maps, which has at least some of the caching but via a separate namespace I think.

  5. KurtCattiSchmidt commented on Feb 25, 2026

    @KurtCattiSchmidt
    Contributor

    This is super interesting. A few questions/potential gotchas:

    1. Existing imports currently go through the module map and use specifiers (without any sort of prefix). Does this proposal imply that a Javascript import foo; and import specifier:foo; are equivalent for script-based specifier imports, or is this proposal only targeted to HTML + CSS?
    2. This is somewhat similar to <base>, and it might be helpful to list out differences or pro's/cons so it doesn't get confused or sidetracked. It also might help to describe how this is expected to work with <base> (I assume specifiers ignore <base>, but I'm not positive, it might still apply after import map resolution).
    3. Script execution has finer control over when script is executed vs parsed via async and defer, so it can wait until all content (including import maps) have been parsed before executing (if desired). HTML has no such constructs, so you could have:
    <link rel="stylesheet" href="specifier:foo" id="first">
    <script type="importmap">
    {
      "imports": {
        "foo": "styles.css"
      }
    }
    </script>
    <link rel="stylesheet" href="specifier:foo" id="second">
    

    ...and only the second <link> would have its bare specifier mapped via the import map. This is different than how resource fetching works in HTML, where the order of parsing the DOM doesn't impact URL resolution.

    One possible solution to this kind of thing would be to introduce async or defer-like attributes for each of these, which won't scale everywhere (e.g. CSS @import doesn't take an attribute, so it would require updates to its grammar, and I would imagine there are other strange cases). Deferring the fetch could postpone the overall load time pretty significantly though, so maybe the ordering dependency is less bad?

    1. With external CSS fetches via <link rel="styleshet"> or @import, you could get race conditions like this:
    <style>
    @import(a.css)) /* this kicks of an async fetch of "a.css" */
    </style>
    

    (where a.css has @import(specifier:foo))

    Then you have:

    <script type="importmap">
    {
      "imports": {
        "foo": "styles.css"
      }
    }
    </script>
    

    a.css gets fetched asynchronously, and parsing continues. The CSS @import fetching behavior is somewhat vaguely spec'd, but the actual behavior in browser engines seems to be async fetches with a synchronous ordered insertion of imported rules once each fetch completes. The async fetch of a.css means that fetching specifier:foo could fail, as it would be racing with the import map parsing.

    One option is to defer these types of fetches until parsing is complete as suggested in 3). Waiting to fetch resources until parsing completes is bad, and this would also break optimizations like the speculative parser. This case seems worse than the ordering dependency in 3), as it's non-deterministic.

  6. sorvell commented on Feb 26, 2026

    @sorvell

    maybe the ordering dependency is less bad?

    That seems fine to me and is, I think, de facto what happens with importmaps and module scripts. For example,

    <script type="module">
      const foo = import('foo'); // not mapped, fails.
      // inject importmap script that maps foo
      const foo = import('foo'); // mapped, works...
    </script>

    you could get race conditions

    If there's ordering, then it seems like the fetching resource (e.g. owning link or style) needs to bake a copy of the importmap to use for any fetches it spawns. Seems like that would avoid a race and be straightfoward to reason about. I hope that's practical.

  7. KurtCattiSchmidt commented on Feb 26, 2026

    @KurtCattiSchmidt
    Contributor

    If there's ordering, then it seems like the fetching resource (e.g. owning link or style) needs to bake a copy of the importmap to use for any fetches it spawns. Seems like that would avoid a race and be straightfoward to reason about. I hope that's practical.

    @sorvell - this wouldn't cover if the document's import maps change during the fetch though. It would have the stale copied version, so the race still exists.

  8. LeaVerou commented on Feb 26, 2026

    @LeaVerou
    MemberAuthor

    @KurtCattiSchmidt Great questions!

    1. Existing imports currently go through the module map and use specifiers (without any sort of prefix). Does this proposal imply that a Javascript import foo; and import specifier:foo; are equivalent for script-based specifier imports?

    Yes, that’s the idea.

    1. This is somewhat similar to <base>, and it might be helpful to list out differences or pro's/cons so it doesn't get confused or sidetracked. It also might help to describe how this is expected to work with <base> (I assume specifiers ignore <base>, but I'm not positive, it might still apply after import map resolution).

    That's an interesting connection. They are quite different: <base> specifies the base URL to use for all relative URLs. It does not affect specifiers, since they are not relative URLs, and it should not affect specifier: URLs since they would be absolute, so that is internally consistent.
    It does apply after import map resolution (see testcase) but that doesn't change with specifier: URLs.

    1. Script execution has finer control over when script is executed vs parsed via async and defer, so it can wait until all content (including import maps) have been parsed before executing (if desired). HTML has no such constructs, so you could have:>
    <link rel="stylesheet" href="specifier:foo" id="first">
    <script type="importmap">
    {
      "imports": {
        "foo": "styles.css"
      }
    }
    </script>
    <link rel="stylesheet" href="specifier:foo" id="second">
    

    ...and only the second <link> would have its bare specifier mapped via the import map. This is different than how resource fetching works in HTML, where the order of parsing the DOM doesn't impact URL resolution.
    One possible solution to this kind of thing would be to introduce async or defer-like attributes for each of these, which won't scale everywhere (e.g. CSS @import doesn't take an attribute, so it would require updates to its grammar, and I would imagine there are other strange cases). Deferring the fetch could postpone the overall load time pretty significantly though, so maybe the ordering dependency is less bad?

    It's not about resource fetching in HTML vs JS, it's about when the UA discovers the specifier.
    Note that this does not work today (testcase):

    <script type="module" async defer>
    	import "foo";
    </script>
    <script type="importmap">
    {
    	"imports": {
    		"foo": "./index.js"
    	}
    }
    </script>

    Neither URLs nor specifiers are revisited multiple times. If the resource being fetched is using specifiers however, these attributes may defer its loading until after the import map has been processed. None of this changes. Yes, it does mean that any resources using specifiers would need to generally come after import maps, but that's not new.

    WRT async/defer for <link>, @import etc, these are orthogonal primitives, and need to be discussed in their own proposals, some of which are:

    specifier: URLs may add to the motivation around them, but neither is blocking the other.

    Btw CSS @import can take additional annotations (media queries, supports(), layer()), so it wouldn't be a huge lift in terms of grammar.

    Note that specifier: URLs don't need to be restricted to CSS and JS. With this, ultimately specifiers could be used anywhere a URL can, including images, videos, import map URLs (alias specifiers to other specifiers!), <iframe src>, SVG <use>, CSS url() etc. I added a note to the OP in case it wasn't clear.

    1. With external CSS fetches via <link rel="styleshet"> or @import, you could get race conditions like this:
    <style>
    @import(a.css)) /* this kicks of an async fetch of "a.css" */
    </style>
    

    (where a.css has @import(specifier:foo))

    Then you have:

    <script type="importmap">
    {
      "imports": {
        "foo": "styles.css"
      }
    }
    </script>
    

    a.css gets fetched asynchronously, and parsing continues. The CSS @import fetching behavior is somewhat vaguely spec'd, but the actual behavior in browser engines seems to be async fetches with a synchronous ordered insertion of imported rules once each fetch completes. The async fetch of a.css means that fetching specifier:foo could fail, as it would be racing with the import map parsing.

    One option is to defer these types of fetches until parsing is complete as suggested in 3). Waiting to fetch resources until parsing completes is bad, and this would also break optimizations like the speculative parser. This case seems worse than the ordering dependency in 3), as it's non-deterministic.

    I don't think it breaks the speculative parser, it just means these particular speculative fetches cannot happen until any import maps have been parsed, which seems fine to me?

    In general, this is assuming the JS behavior where undefined specifiers fail early. JS has very good reasons to handle them that way, but we are not bound by the same constraints everywhere in the platform. For independent fetches that don't affect anything else, such as CSS @import, there is no reason to fail eagerly if you encounter a specifier: URL you can't resolve, you could just wait longer.

    Also, we should define @import fetching less vaguely! Would you mind opening an issue?

  9. sorvell commented on Feb 27, 2026

    @sorvell

    WRT async/defer for , @import etc, these are orthogonal primitives, and need to be discussed in their own proposals

    This makes sense to me. The race condition @KurtCattiSchmidt points out exists today with importmaps and js modules. Here's a test case (try setting the timeout in barMapDelay to be > barImportDelay).

    In general, I think the best practice with importmaps is to define them early and as long as you do that, it shouldn't be an issue?

  10. noamr commented on Aug 6, 2026

    @noamr
    Contributor

    The main issue with this is that it doesn't answer the question of how you use modules from the map in those places, regardless of the import map.

    e.g. let's say you don't have an import map at all, but you are using a module in /style/theme.css.

    Right now calling @import "/style/theme.css" would re-fetch that URL, ignoring the module map. A specifier: scheme is not the right primitive for this.

    I think what's needed is a map of places where modules can be reused alongside non-modules, and see what is the right way to specify that the importing happens from the module map (and referring to the import map as part of that) rather than as a regular fetch.

    It could be @import module "/style/theme.css".
    We can go with @import "module:/style/theme.css" which might mean also @import module:https://cdn.example.com/style.css".

    When looking at the use cases - I wouldn't jump to a generic solution though it might be tempting. Including HTML modules in <iframe src> or SVG modules in <use>, or image modules in CSS url() sound like possible future use case but in fact bring a lot of questions and complications about mutability, that might lead us to a completely different syntax.

  11. robglidden commented on Aug 14, 2026

    @robglidden

    In light of the new "Style Module Imports via <link> Elements" explainer ...

    I think only a small set of HTML attributes would actually benefit from SpecifierOrURL handling, and for those I think a new attribute, say importfrom, is worth considering over a protocol.

    <link rel="stylesheet" 
      href="/path/to/theme.css" 
      importfrom="themestyles" 
    />

    Of the 14 URL-bearing attributes in 27 HTML elements (please expand and check my list and reasoning below), and excluding ~13 additional obsolete attributes, really only <link href> and plausibly ~2-3 others are good candidates. This comment doesn't address CSS or SVG.

    I note that during the original design of import map, an import: scheme was proposed in 2018, scaled back to only CSS and HTML, and ultimately dropped in 2021.

    What was not considered then, and I think should be now, is a new attribute like importfrom.

    An importfrom attribute offers distinct advantages over a protocol:

    In the specific case of "Style Module Imports via <link> Elements":

    • it avoids a confusing repurposing of type to type="module"
    • it avoids making href a dual-purpose attribute which triggers different behaviors of the link element itself, which is confusing and error-prone

    I note the design principle above already names overloading href as a mistake not to repeat:

    Note: HTML has a number of legacy inconsistencies that should not be emulated, like the way link's href attribute might allow for navigation or for resource loading, depending on the value of the element's rel attribute.

    SpecifierOrURL processing rule:

    If importfrom is present and supported, it wins and href is ignored.

    • browser without support: ignores the unknown attribute, uses href, loads a working stylesheet. No error, no console noise
    • browser with support: resolves importfrom through the import map, ignores href
    Elements with URL attributes and reasoning

    I examined the WHATWG HTML attributes index and cross-checked for example against the spec's own parse a URL call sites, and against Gecko's URL-attribute table, a literal array, kURLAttributesHTML.

    Filtering the attributes index on the string "URL" alone is not enough. srcset and <meta http-equiv=refresh content> have URLs in a larger syntax and don't declare "URL" as their value type.

    I found 14 URL-bearing attributes, across 27 elements:

    • href: <a>, <area> (navigate on activation), <link> (behaviour depends on rel), <base> (sets the document base URL)
    • src: <img>, <script>, <iframe>, <embed>, <source>, <video>, <audio>, <track>, <input>
    • srcset: <img>, <source> — URLs inside image candidate strings
    • imagesrcset: <link> — URLs inside image candidate strings
    • poster: <video>
    • data: <object>
    • action: <form> — submission target
    • formaction: <button>, <input> — submission target override
    • ping: <a>, <area> — space-separated URL list, POSTed out-of-band
    • cite: <blockquote>, <q>, <ins>, <del>
    • itemid, itemtype, itemprop: global microdata attributes
    • content: <meta http-equiv=refresh> — URL inside a text value; declared value type is "Text"

    ~13 obsolete attributes: longdesc, archive, codebase, classid, profile, manifest, background, lowsrc, and so on. I don't see value in retrofitting these for SpecifierOrURL handling.

    Of the 14, 2 are clear candidates for SpecifierOrURL today:

    <img src> / <img srcset> are plausible, giving at most 4.

    I excluded the rest for 3 reasons:

    Never dereferenced (5). cite, itemid, itemtype, itemprop, and <base href>. Nothing fetches these, so there is nothing for import-map resolution to do. All three browser engines omit itemid/itemtype/itemprop from their URL-attribute tables (e.g. Gecko's kURLAttributesHTML). itemtype values like https://schema.org/Person are deliberately stable global identifiers, and remapping would defeat their purpose. base href is itself a resolution mechanism.

    Fetch, but no module-graph use case (5). action, formaction, ping, poster, and <track src>. These fetch or navigate, but nobody has asked for import-map-resolved form endpoints or ping URLs.

    Navigation or document/plugin loading, not module loading (4). <a href>, <area href>, <meta refresh content>, and data on <object> (along with <iframe src> and <embed src>). These name documents to navigate to or embed, not resources to load into a module graph.

    That leaves srcset and imagesrcset. These would need something other than a parallel importfrom, because the URL is not the whole attribute value, it is in a comma-separated microsyntax with w/x descriptors.

  12. noamr commented on Aug 14, 2026

    @noamr
    Contributor

    @robglidden if we have <link rel=stylesheet type=module>, what is the advantage of having either specifier: or importfrom? Where would you use this outside of importing stylesheets?

  13. deleted a comment from wafir64695fcqs on Aug 14, 2026
  14. robglidden commented on Aug 17, 2026

    @robglidden

    @robglidden if we have <link rel=stylesheet type=module>, what is the advantage of having either specifier: or importfrom?

    @noamr:

    To me,<link rel=stylesheet type=module> is better than specifier: but importfrom is better than both, because it offers a progressive enhancement strategy, avoids a hard fail on non-supporting browsers, and avoids repurposing existing attributes to subtly-new semantics.

    Summarizing:

    Referencing method On non-supporting browsers On supporting browsers
    <link rel=stylesheet type=module> silent hard fail,
    no onerror()
    loads the stylesheet as a module
    specifier: console hard fail,
    does onerror()
    loads the stylesheet as a module
    importfrom loads the stylesheet as a normal stylesheet loads the stylesheet as a module

    This may help address 2 open issues in the "Style Module Imports via Elements" explainer:

    1. Should we attempt to make this feature backward-compatible with classic elements, or are there too many differences?

    2. Is href the right way to go, even though it goes through import map processing? Should we use a new attribute such as moduleimport?

    Where would you use this outside of importing stylesheets?

    The list of candidate url-loading existing elements is small, this comment (please recheck!) identifies only <link href>, <script src>, <img src>, <img srcset> of existing HTML elements. I think one could also add the SVG element <use href>.

    But the idea of different situation-specific URL attributes depending on context is well established: 14 URL-bearing attributes, across 27 elements.

    From all this it seems to me:

    • The original concern of "ad hoc forever" is not so large for existing HTML and SVG elements as to alone warrant a new protocol (not considering CSS).
    • Consistent declarative SpecifierOrURL referencing/processing is likely more a going-forward concern than a going-back concern, and a new attribute like importfrom is likely a better and more precedent-based and platform-design-principles-based solution than a new protocol like specifier:.

    Also, I think the full set of import parameters should be considered, and not just munge "specifier" with "import map key":

    import { export1 as alias1 } from "module-name" with { type: "..." };

    There are several potential overlapping and conflation issues there ("type", "as", "with", default, etc) when remapped to a smaller set of declarative attributes and import map processing.

  15. noamr commented on Aug 18, 2026

    @noamr
    Contributor

    Ah ok for progressive enhancement we could do that or:

    link rel="stylesheet module"

    Which would ignore "module" on unsupported browsers without introducing a new attribute.

    The thing is that it will still fail on unsupported browsers if using module specifiers from the importmap, which makes me think that it's perhaps better for it to fail rather than sometimes succeed and sometimes fail... But I am not sure.

  16. LeaVerou commented on Sep 15, 2026

    @LeaVerou
    MemberAuthor

    I think we need to distinguish import-as-module (make a resource part of the module graph) vs specifier import.
    Importing a URL as a module does not automatically allow us to use specifiers, and last I checked Style Module Imports did not account for specifiers at all.
    Specifiers are essential for proper dependency management on the web platform. They decouple a dependency from…

    • the location of its package (CDN, local, etc)
    • its exact file path within the package
    • its exact version in the current context

    Even a <script> element, which already supports type=module, does not actually support specifiers.
    And there are many use cases for importing non-JS assets, from CSS libraries to icons, graphics, media files, etc. for which the web platform currently has no good story.
    Sure, we could introduce ad hoc syntax for every single case. And then more ad hoc syntax in CSS, and more ad hoc syntax in SVG, and so on. This is exactly what this proposal aims to avoid. The more special syntax we add, the more the API surface authors have to learn, and the slower the rate of progress because everything now requires a bikeshedding session .
    Or we can target the one syntax all of these understand: URLs.

    This does not negate the value of supporting type=module on certain resources to add a (regular) URL to the module graph. These are separate things.

  17. noamr commented on Sep 27, 2026

    @noamr
    Contributor

    I think we need to distinguish import-as-module (make a resource part of the module graph) vs specifier import. Importing a URL as a module does not automatically allow us to use specifiers

    The main point is that importing from the specifier map means that the resource is imported from the module graph.
    In what cases does importing from the module graph doesn't go through the importmap?

    and last I checked Style Module Imports did not account for specifiers at all.

    I think it does?
    import sheet from "theme-styles" with { type: "css" } should check the import map for a theme-styles specifier.

    Even a <script> element, which already supports type=module, does not actually support specifiers.

    Can you expand on that? specifiers are part of an importmap and are supported whenever a module import is supported (not to be confused with CSS @import unfortunately).

    And there are many use cases for importing non-JS assets, from CSS libraries to icons, graphics, media files, etc. for which the web platform currently has no good story. Sure, we could introduce ad hoc syntax for every single case. And then more ad hoc syntax in CSS, and more ad hoc syntax in SVG, and so on. This is exactly what this proposal aims to avoid. The more special syntax we add, the more the API surface authors have to learn, and the slower the rate of progress because everything now requires a bikeshedding session . Or we can target the one syntax all of these understand: URLs.

    We would need ad-hoc understanding of what importing from the module graph means in all these cases... what does it mean for SVG to import from the module graph?
    A specifier URL doesn't solve anything in that regard... if at some points certain parts of SVG fetch via the module graph, they should also resolve URLs using the importmap.

    The importmap is nothing but a glorified URL alias system for the module graph... A custom scheme is the wrong abstraction for that IMO as it's not valid anywhere outside the module graph and it always needs to be consulted with when importing from the module graph anyway.

  18. LeaVerou commented on Sep 27, 2026

    @LeaVerou
    MemberAuthor

    @noamr

    <script src="foo" type="module"></script> will not use a foo specifier: foo in that context already has a defined meaning, it's a relative URL to the file called foo. Try it. 🙂

    That is literally the whole point of this proposal. You cannot retrofit specifiers in places designed for URLs, because they are already interpreted as relative URLs and we cannot change that. No wonder you reached the conclusion that there is no point if there's such a fundamental misunderstanding.

    Last I checked style module imports were also framed around URLs, including plain relative URLs, which preclude specifiers from ever being supported in these places.
    By style module imports I'm not referring to CSS modules, I'm referring to the new <link rel=stylesheet import="foo.css"> proposal.
    ESM imports avoided this entire problem by not allowing these: a relative URL has to start with ./ or ../.

    Specifiers are indeed an abstraction over URLs — an essential one for dependency management. The reason people use specifiers is not because they look a little prettier. It's because they decouple a dependency from:

    • the exact location of the package
    • the exact file path within the package (which often changes between versions)
    • the exact version, for the source referencing
    • the import conditions (e.g. browser, node, typescript, etc)

    Worse, lack of specifiers rules out transitive dependencies because there's nothing reasonable to reference.

    Specifiers are not a nice-to-have.
    Until we can use specifiers everywhere a dependency may be useful, the web platform is bound to depend on bundlers forever for dependencies (and still have "dependency management" come 3rd as a pain point). You may think this is fine, but we should all be aware of what future we are designing for the web platform.

    Perhaps the mistake of this proposal was coupling specifier: with the module graph. They can be entirely separate. It's a bit of a missed opportunity, but it does alleviate the core pain points this proposal was designed to address.

  19. noamr commented on Sep 28, 2026

    @noamr
    Contributor

    @noamr

    <script src="foo" type="module"></script> will not use a foo specifier: foo in that context already has a defined meaning, it's a relative URL to the file called foo. Try it. 🙂

    I think we can make this work directly from the import map without changing the URL?
    In any case, this does not seem particularly useful.

    It would only do something special if it's a module that's not anyway imported from somewhere else, and it's just 2-3 characters more than <script type="module">import "foo"</script>

    That is literally the whole point of this proposal.

    It's a side note in the OP. The OP is mostly about styles etc.
    When importing styles, we would need access to the module graph regardless of specifiers.
    The @import (e.g. @import "https://example.com/style.css") needs to know if it gets the style from the module graph or by fetching.

    Last I checked style module imports were also framed around URLs, including plain relative URLs, which preclude specifiers from ever being supported in these places. By style module imports I'm not referring to CSS modules, I'm referring to the new <link rel=stylesheet import="foo.css"> proposal. ESM imports avoided this entire problem by not allowing these: a relative URL has to start with ./ or ../.

    Style module imports go to the importmap first as currently specified.

    Specifiers are indeed an abstraction over URLs — an essential one for dependency management. The reason people use specifiers is not because they look a little prettier. It's because they decouple a dependency from:

    • the exact location of the package
    • the exact file path within the package (which often changes between versions)
    • the exact version, for the source referencing
    • the import conditions (e.g. browser, node, typescript, etc)

    Worse, lack of specifiers rules out transitive dependencies because there's nothing reasonable to reference.

    I love the importmap, there is no argument about that.

    Perhaps the mistake of this proposal was coupling specifier: with the module graph. They can be entirely separate. It's a bit of a missed opportunity, but it does alleviate the core pain points this proposal was designed to address.

    Yea if this proposal expands to make the importmap or an equivalent into more of a global URL alias list outside the module graph I think having a URL scheme for it would make sense.

    For example what would fetch("speifier:foo") do? Should it just take the URL from the importmap and re-fetch it? Does it expect the underlying module recoerd to also cache the response and return a clone of that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    addition/proposalNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interesttopic: imports/exportsImport maps, specifiers, imports, exports

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions