Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I_16 #16

Open
noopn opened this issue Sep 10, 2018 · 0 comments
Open

I_16 #16

noopn opened this issue Sep 10, 2018 · 0 comments

Comments

@noopn
Copy link
Owner

noopn commented Sep 10, 2018

AMD和CMD的区别

共同点就是都是一种框架在推广的过程中对模块定义的规范产出
AMD即Asynchronous Module Definition,翻译过来就是异步模块化定义,解决了前端开发过程中的两大问题,一个是文件之间的依赖问题,一个是浏览器加载多个JS文件时页面失去响应的时间过长。
CMD即 common moudle definition,翻译过来即通用模块定义,
AMD推崇依赖前置,CMD推崇依赖就近。
AMD和CMD最大的区别不是说上面的两点,而是他们俩对依赖模块的执行时机有所不同!!!对依赖模块的执行时机取决于他们的模块定义方式,AMD推崇依赖前置,因此,JS可以及其轻巧地知道某个模块依赖的模块是哪一个,因此可以立即加载那个模块;而CMD是就近依赖,它要等到所有的模块变为字符串,解析一遍之后才知道他们之间的依赖关系,这在别人看来是牺牲了性能换来开发的便利性。

webpack tree shanking

webpack 打包commonjs规范

webpack 打包es6 模块化规范

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant