Best approach optional settings jQuery plugin
<p>Take a <em>very</em> simple jQuery plugin boilerplate:</p>

<pre><code>var _defaults = {
  foo: false
};

function Plugin( settings ) {
  this.opts = $.extend( {}, _defaults, settings );
}
</code></pre>

<p>I have a <code>doSomething</code> method that can only run successfully if the option <code>foo</code> is set to <code>true</code> and there are other methods that may <code>doSomething()</code> at a certain point so I had a dilemma on where to place my <code>if</code> statement. First I thought:</p>

<pre><code>Plugin.prototype = {
  doSomething: function() {
    // Do something that depends on foo
  },
  method: function() {
    ...
    if ( this.opts.foo ) { this.doSomething() }
  },
  method: function() {
    ...
    if ( this.opts.foo ) { this.doSomething() }
  }
};
</code></pre>

<p>But then for the sake of DRYness I decided to do this:</p>

<pre><code>Plugin.prototype = {
  doSomething: function() {
    if ( this.opts.foo ) {
      // Do something that depends on foo
    }
  },
  method: function() {
    ...
    this.doSomething();
  },
  method: function() {
    ...
    this.doSomething();
  }
};
</code></pre>

<p>So now methods that may utilize <code>doSomething</code> run the function regardless of it being empty if <code>foo</code> is <code>false</code>.</p>

<p>So my question is, what is a better approach? The second one is shorter but it has to look-up the method everytime even if it's not necessary just to perhaps run an empty function. So is the first one more efficient? </p>

<p>Oh, and yes, I know probably this is micro-optimization and folks will say don't worry about it but I'm just curious...</p>
