Node.js & Electron: Where to require several modules?

末鹿安然 提交于 2020-01-05 07:00:52

问题


Requiring 5-10 modules in a javascript file (eg. app.js) in a html file/render process window takes about 5 seconds to render that window, although the window is already visible. These required modules are needed for other windows as well, which seems slow. I understand that require is also synchronous.

Therefore, should I:

  1. make this asynchronous, or
  2. require these modules globally for current and new windows, or
  3. call these via ipc from main.js if this is faster?, or
  4. make this faster more practically some other way?

来源:https://stackoverflow.com/questions/44510139/node-js-electron-where-to-require-several-modules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!