Modules and dependencies known before the load

Ian Hickson ian at
Fri Aug 15 09:50:19 PDT 2014

On Fri, 15 Aug 2014, Kevin Smith wrote:
> >
> > Can you elaborate on this, just so I'm sure I understand it right?
> The execution order is determined by a depth-first traversal of the 
> dependency graph starting with the node being loaded, where edges are 
> ordered.  So adding edges can have an effect on the traversal ordering. 
> Execution order is in general not fixed, though, since the user can 
> initiate loads of different parts of the graph at arbitrary times.  
> Just something to consider.

Ok, cool, that's what I thought. Thanks.

> > > 2) The ability to prefetch resources, given a URL which is currently 
> > > loading.
> As Juan pointed out (and I forgot) this can be done with 
> Loader.prototype.load.

The problem with doing this is that it requires that the dependency tree 
be redundantly managed in two places: once on the HTML side, and once on 
the ES6 side. I would really like to avoid browsers having to implement 
two more or less identical dependency systems.

> I think there's an important distinction here.  Let's say that you have 
> this dependency chain:
>     A -> B -> C
> So A depends on both B and C.
> Let's say that the user has declaratively indicated that A also depends 
> on some other resource D, but A doesn't *actually* depend on D.  How 
> should things be modeled in that case?  Would it make sense to add an 
> edge from A to D?
> If D is an "actual" dependency, then you would want to 
> execute/initialize it before A.  On the other hand, if it's just a 
> "likely" dependency, then you might want to load it (and it's 
> dependencies) without initializing it, using `Loader.prototype.load`, or 
> perhaps some other mechanism.

Ah, I see.

I think it would be reasonable for us to say that all the dependency 
declaration mechanisms are equivalent in that they all cause the target 
dependency to be "executed" (whatever that means in the context). This 
might need careful management around some resource types, though. In 
particular, CSS imports don't de-dupe, so we'd have to say what it means 
if you do:

   <style depends-on="my-other-stylesheet">
     @import url(my-other-stylesheet);

Does this cause "my-other-stylesheet" to be loaded twice?

But that's probably out of scope for this list.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the es-discuss mailing list