This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 21253 - [Imports]: Consider changing component location to component identifier
Summary: [Imports]: Consider changing component location to component identifier
Status: RESOLVED MOVED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Dimitri Glazkov
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 23278
  Show dependency treegraph
 
Reported: 2013-03-11 19:52 UTC by Steve Orvell
Modified: 2015-07-06 08:12 UTC (History)
3 users (show)

See Also:


Attachments

Description Steve Orvell 2013-03-11 19:52:10 UTC
The spec currently requires that 2 components have knowledge of the same url to share a dependency. This is often inconvenient and it's common for module loaders to use a name as a component identifier instead of a url (http://requirejs.org/docs/api.html#jsfiles) to avoid this problem.

Here some options for addressing this limitation:

Option 1: <link rel="component" name="foo-component" href="...">

To support this type of usage, we could modify the "component location" concept to be "component identifier." We would allow an optional name attribute to be on the component link tag. The component identifier definition would be something like this: 

"component identifier
The component identifier must be the value of the link element's name content attribute. If that attribute does not exist or is empty string, it is the result of resolving the URL given by link element's href content attribute, relative to the element, or empty string if that fails."

Option 2: <component name="foo-componnet"> (inside the component)

We could also allow components to specify an identifier for themselves. This might be done by using a <component> tag with name attribute inside the component.
Comment 1 James Simonsen 2013-07-19 21:31:15 UTC
I'd love to see something like this.

One of the things that's bothered us is having a dozen different copies of jQuery in the cache. They all come from different URLs and are fetched and cached separately. It'd be so much nicer if we could just download it once.

So, if we could expand this beyond components, or perhaps make sure that components can accommodate simple JS libraries, that'd be great. It could be a matter of being able to specify a script by name, or have components follow the same evaluation rules as <script>. That doesn't sound great though.

My biggest concern is management of the namespace. You wouldn't want to have conflicts between sites. Even worse would be if a site poisoned a name by injecting a malware script in there. Maybe we need a hash of the content as well?
Comment 2 William Chan 2013-07-20 02:02:57 UTC
RequireJS doesn't try to globally address resources by content/id. Instead, it relies on a component identifier + baseURL as described in Steve's link which says: "RequireJS loads all code relative to a baseUrl." What this encourages is every website self-hosting its own web components if they want to use these component identifiers. If we want to allow this to be done globally, then we start running afoul of security concerns, some of which are fixable by a hash, but there's also the Content-Security-Policy issue. See https://news.ycombinator.com/item?id=4516193 for details with explanations from agl & abarth.

AIUI, the main value of this proposal is making component loading easier for web developers. And I agree strongly with this. Component loading with explicit URLs can often be a PITA.

One downside of the RequireJS approach is that the module loading is all done in JS and is opaque to the rendering engine's preloader. It'd be great if any solution we propose here enables the preloader to understand the resource loading so it can issue resource requests sooner.
Comment 3 Dimitri Glazkov 2013-09-18 19:48:05 UTC
This is not something we'll tackle in this iteration of the spec. It sounds awesome and awesomely complex.
Comment 4 Hayato Ito 2015-07-06 08:12:54 UTC
Moved to https://github.com/w3c/webcomponents/issues/235