I know for a fact that unused Java/.NET imports won't affect performance.
But I also know that implementations of require()
(used to?) simply pull and concatenate the entire required module/file at compile time, and that the import
statement is sort of an evolution of that. Is it actually different? Will forgetting a very big unused ES6 module in the import list affect my app's performance?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yes, it will definitely affect performance, especially if you have non-exported code that does something non-trivial in the module or the module imports other modules. The first time you import a module it will be executed once (and only once). According to the spec:
http://www.ecma-international.org/ecma-262/6.0/#sec-abstract-module-records
Do nothing if this module has already been evaluated. Otherwise, transitively evaluate all module dependences of this module and then evaluate this module