Adding out-of-band dependencies for a module

Ian Hickson ian at
Mon Aug 11 17:06:35 PDT 2014

So I'm trying to figure out how to spec the HTML spec's Loader.

One of the things that we're likely to add as part of this is a generic 
dependency system. Authors have long asked to be able to do things like 
define that their scripts depend on CSS or images or whatnot. If we 
introduce a global attribute for this is HTML, say needs="", then it will 
be possible to do something like:

   <script type=module needs="foo" href="foo.js"></script>

...where "foo" is an ID to some other element.

So far so good. However, I don't see how to actually add these 
dependencies to the Load Record's [[LinkSets]]. In the instantiate hook, I 
can either override the behaviour entirely (providing my own dependency 
list, but also having to evaluate the code myself and return an eventual 
Module), or I can return undefined and let the ES spec handle all of it, 
with no way to add explicit dependencies.

I guess since the HTML spec is going to be calling both LoadModule() and 
EnsureEvaluated() for each module declared by <script type=module>, one
solution is just to handle these myself, and not call EnsureEvaluated() 
until all the dependencies are ready as well as the LoadModule() promise 
being resolved. In that the expected behaviour?

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

More information about the es-discuss mailing list