Fwd: "delay" keyword
bruant.d at gmail.com
Thu Jul 5 08:41:51 PDT 2012
Le 05/07/2012 17:19, Patrik Stutz a écrit :
> BUT: interestingly, the import keyword also seems to be synchronous.
> So, I think behind the scenes there still would have to be something
> like a "delay" function to make it non-blocking. Or am I missing
The 'import' keyword is synchronous, but in a different than node.js
var a = require('a.js');
var b = require('b.js');
var c = require('c.js');
Here, a.js is fetched, parsed and executed, then b.js is fetched, parsed
and executed, then c.js is fetched, parsed and executed. In that order
import a from 'a.js'
import b from 'b.js'
import c from 'c.js'
Here, a.js, b.js and c.js are fetched and parsed in parallel, but
executed in the order they are declared. If other imports are found in
parsing phase, these can be fetched and parsed in the background.
The most important part being parallel and in depth fetch since network
is the performance bottleneck in web applications.
If you want delayed module loading (with a custom delay), you can always
fetch the scripts yourself and eval them.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss