Search code examples
jqueryamdbrowserifycommonjs

Will it be slow if a module is `required` several times in Browserify?


For example, codes in a.js looks like this

require('b')
$=require('jquery')
$.ready()

And codes in b.js looks like this

$=jQuery=require('jquery')
$.ready()

If I set a.js as the entry point, what will happen, as 'jquery' is required twice, will it be loaded twice?


Solution

  • Just like in Node, the module code is only evaluated once. You can try this by putting a console.log statement in your module.