browserify – write client-side javascript server-side


Unifying your front-end and back-end codebases can be a harrowing experience. Regardless of your web technology stack of choice, you’ve probably created some server-side component which generated some front-end JavaScript for you at some point. I’ve created and used many tools that do such code generation, and I’ve hated all of them. This is why I’m soo excited to see node-browserify by prolific Node.js module author,James Halliday.

browserify is a node.js library which helps you share your back-end code to the front-end by enabling such features as:

  • a client-side require() method
  • being able to load npm packages
  • a middleware system for code generation:
    • minify
    • uglify
    • ES5 compatibility
    • fileify ( wrap static files or directories in JavaScript methods )
  • a CLI tool for creating stand-alone bundles
  • full integration with node’s httpServer and Express
  • browser-versions of certain core node modules such as path, events, and vm

Browserify does a great job of simplifying the process of sharing code between the browser and server by building on top of existing infrastructure and providing some great new features that play very nice with node.js

I needed to build a library that would operate dual-sided ( front-end and back-end ), and I choose to build it server-side first and then use the browserify CLI tool to port it to the client ( and work as a standalone with no server dependencies ). The entire process worked out much better then expected and I’d recommend trying it out for your next JavaScript project.

If you’d like to see an example of node-browserify in production, you can check out Browserling, Mr. Halliday’s very own company which allows you to test websites cross-browser, in your own browser! I can only imagine what crazy libraries SubStack will think up next.

Related Posts: