It would be helpful if there was a way that the module _execution_ (after 
it's been parsed and dependencies have been extracted) could be delayed 
by the loader.

Suppose a page is loading and has reached a quiescent state, and so the 
browser thinks "ok, time to preload some scripts". It might start with one 
script, and then find that it imports another, and would then fetch that 
one. But it doesn't want to actually execute anything, because the scripts 
haven't been invoked yet.

Since ES6 does all the heavy lifting of finding the imports in the source 
code and setting up all the linking, it would be good if the browser could 
rely on that but just put a stop to the final execution step until such 
time as the resource is actually needed.

This would also allow for ES6 import syntax to be used inline to declare 
some dependencies, as in:

   <script type=module when-needed>
     import "jquery";
     import "jquery/animations";
     import "myapp/logic";
   </script>

If the browser could notice that this was an inline script and have the 
ES6 module system pre-parse it to discover the imports, it could preload 
them and then when the <script> element's execute() method is invoked it 
could just unblock the execution and immediately have the scripts run.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to