I'm using Underscore.js in my project. Almost all files have this line of code: var _ = require('underscore')
.
The require
function is synchronous so the same file is loaded each time it is used. Is this the right thing to do? Doesn't this affect performance?
Instead of this, is it okay to define a global variable in the app.js
file?
_ = require('underscore')
I've read that you shouldn't use global variables, but this seems to be a valid use case.