Reputation: 341
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.
How should I split between browser-compatible code and code that uses node API?
The way I see it, I could do one of the following:
What should I do to solve this?
Upvotes: 3
Views: 1146
Reputation: 276266
I know this is an old question, however, today it is possible easily with Browserify. Browserify lets you write nodejs modules with require()
syntax and have them converted to browser complain code easily!
They even ported zlib
which you mention to work with it, so that dependency is OK.
I hope this helps future readers, browserify helped me :)
Upvotes: 4