Loading modules into a single file slows down app performance?

1

My project has several modules, if I load them all into a file - modulos.js -, am I lowering the performance of the app? ex:

file that loads modules (modulos.js):

 exports.var1 = require("...")
 exports.var2 = require("...")

File 1:

    modulos = require(modulos.js)

    modulos.var1.funcao()
    modulos.var2.funcao()

File 2:

   modulos = require(modulos.js)
   modulos.var1.funcao()
    
asked by anonymous 20.08.2016 / 19:57

1 answer

0

Charging all modules in a file or loading each module seems to me irrelevant.

Node.js places each module in memory and does not reload the module if it is requested again. If there are N files that need a module it serves as memory.

I even advise that each file requires the modules you need at the beginning of the file. Thus each module becomes more watertight and if it is necessary to remove it or use it elsewhere it is easier to control its real dependencies.

    
21.08.2016 / 08:10