Reputation: 7809
I've been writing some pseudo-oop JavaScript using the Module pattern. I'm curious, what is the best way to handle dependencies on libraries in my JavaScript modules?
For example, if my module makes use of the jQuery or Underscore libraries, is there a way I should be passing in a reference to those, or should I just use them assuming that they will have what they need from the other scripts passed into the page?
Upvotes: 2
Views: 170
Reputation: 1789
It's best if you pass them in as a reference. It's kinda like importing a library:
(function(JQuery) {
...
})(jQuery);
Upvotes: 2