I have recently been digging into Electron and nwjs as options for deploying a web application to desktop computers as an installable binary. While both are similar technologies utilizing Node.js and Chromium, I have noticed some subtle differences that affect my development workflow (beyond just purely technical differences).
UPDATE: I wrote a follow-up to this post!
In full transparency, here are the exact versions of both tools that I’m using:
- Electron v0.25.2
- nwjs v0.12.0
At the time of this writing, these are the latest versions of both.
The electron repo has a good document defining what they believe to be the differences between electron and nwjs — be sure to give that a read. For me, those technical differences didn’t really affect my decision towards either tool but they’re definitely worth noting.
Both electron and nwjs are really easy to get started — I had a running app within minutes in both tools.
However I did notice a gigantic difference in file size for the “production” builds I created. Both projects have decent documentation on creating a rebranded binary on multiple platforms — and for my app (18MB compressed static web content) the clearly smaller build output came from electron (117MB total for OSX, with no asar compression), while nwjs created a huge 220MB binary for OSX (no V8 snapshot).
That’s not a scientific study on these tools, and it’s certainly possible I’m not optimizing some things perfectly… but the 18MB of static web content (my app) is then wrapped in a rather sizable (100/200MB) of extra stuff.
Furthermore, my app seems to launch faster in electron — which may just be the result of starting in the Node context (electron) compared to starting in the Web context (nwjs).
On the other hand, creating a rebranded binary across platforms seems much easier using nwjs.
I use grunt for my local build process, and nwjs has a ton of grunt plugins to make this process smooth and easy (although I didn’t actually try to build a Windows executable).
electron has some grunt plugins — but they’re not updated frequently, and the usage is confusing. In particular, grunt-build-atom-shell is super confusing as you have to tell it what tag/commit of electron to use IN ADDITION TO the magical custom version of Node that tag/commit depends on. Because I obviously know that.
Protecting Source Code
In nwjs you can build an executable using a V8 snapshot of some kind. I didn’t really dig into what that is or how it works, but the repo makes it clear that you’ll take a 30% performance hit. Ouch.
In electron, you can build using an ASAR archive. This is really, really easy to do — and there’s a great grunt plugin for that! On the downside, I have to imagine that an ASAR archive can be cracked relatively easily… but it’s better than plaintext.
And the winner is…
At the end of the day, I’m moving forward with electron. I like that it’s officially sponsored by GitHub — and Visual Studio Code was just released using it, so that’s a pretty good endorsement!
The custom branded binaries will be a bit problematic for me, but the rest of the build process isn’t bad. Certainly the smaller size of the final executable is a plus!
What are your thoughts?
Is anyone out there using these tools? What are your thoughts?
Please feel free to offer some insight on your experience — I’d love to know if there are other considerations I should make, or if I’m not doing things the best way.