Making a browser and node compatible Javascript library
<p>I am attempting to make a javascript library which I would prefer to be compatible with both browsers and node. However, there is some functionality offered in the node API that isn't offered in browsers (such as compression). I know it would be possible to code this functionality in javascript so it would be cross-compatible, but the node native compression will probably perform much better as it is much lower level.</p>

<p>How should I split between browser-compatible code and code that uses node API?</p>

<p>The way I see it, I could do one of the following:</p>

<ul>
<li>make 2 separate scripts, one for node and one for browsers</li>
<li>make my code figure out the environment it is in and act accordingly</li>
<li>make all my code the same, but lose some performance improvements I would have had in node</li>
</ul>

<p>What should I do to solve this?</p>
