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 something?
The 'import' keyword is synchronous, but in a different than node.js 'require':

    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 sequentially.


    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.

David
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to