What about the asynchronous loading of JS modularization?

such as the title, found a lot of information did not understand, can you give a popular explanation?


CommonJS is a dynamic synchronous import, applied to the server side, and the files are local, even if the main thread is blocked. And because it's still dynamic, you can load the module through require ('${path} / xxx.js') .

and ES Module , that is, import and export module in the way of improt/export , which is asynchronous, because when it is applied to the browser, files need to be downloaded, and synchronous import will have a great impact on rendering.

Menu