Why is the nodejs CommonJS Synchronize and the front-end amd,cmd asynchronous? What about the es6 module?

Why is the nodejs CommonJS Synchronize and the front-end amd,cmd asynchronous? What about the es6 module?

Mar.20,2021

for the backend, Synchronize loading is not a problem, because

  1. modules are all local, and the waiting time is the hard disk time;
  2. once started, it usually does not turn off, and reliability is more important than startup time.

for the front end

  1. modules are all on the server and need to be requested through the network, which is too slow;
  2. Synchronize xhr will block browsers. If you fake death, the user experience is poor, and the time of the first screen is very important.

when designing the es6 module, you didn't force Synchronize or async. But all browsers add defer by default to < script type= "module" > < / script > , so it can also be considered asynchronous.

Menu