83

We are planning to built cross platform desktop application. We found that Node-Webkit is a perfect choice for us. But GitHub developed their own framework called Electron instead of using Node-Webkit.

What is the difference between them?

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Fizer Khan
  • 88,237
  • 28
  • 143
  • 153
  • 2
    **E**lectron vs **N**W.js (April'17). Stackoverflow questions [E: 2,630](http://stackoverflow.com/questions/tagged/electron) vs [N: 269](http://stackoverflow.com/questions/tagged/nw.js), Github pull requests [E: 102](https://github.com/electron/electron/pulse/monthly) vs [N: 6](https://github.com/nwjs/nw.js/pulse/monthly), apps built on [Electron](https://electron.atom.io/apps/) vs [NW.js](https://github.com/nwjs/nw.js/wiki/List-of-apps-and-companies-using-nw.js) and finally [Google Trends](https://trends.google.com/trends/explore?q=nwjs,electron%20js) - Electron seems to be better choice. – kinjelom Apr 21 '17 at 11:07
  • I've chosen 'nw.js' as I can just point it at my 'index.html' and it just works. With 'nw.js' I feel like I am programing for a browser with 'node.js' added instead of 'node.js' with a browser bolted on top approach of 'Electron' - and that in my opinion is the better paradigm and approach. – Daniel Sokolowski Mar 30 '18 at 14:18
  • Good read: http://tangiblejs.com/posts/nw-js-and-electron-compared-2016-edition – Daniel Sokolowski Mar 30 '18 at 14:20
  • 1
    https://xpda.net gives a quick pros/cons list of several dozen tools, including NW.js and Electron. Can be filtered by technology and platform support. – Jaredcheeda Mar 03 '21 at 15:18

1 Answers1

81

Electron has a page explaining the differences with nwjs.

Like NW.js, Electron provides a platform to write desktop applications with web technologies. Both platforms enable developers to utilize HTML, JavaScript, and Node.js. On the surface, they seem very similar.

There are however fundamental differences between the two projects that make Electron a completely separate product from NW.js.

  1. Entry of Application In NW.js, the main entry point of an application can be an HTML web page. In that case, NW.js will open the given entry point in a browser window.

In Electron, the entry point is always a JavaScript script. Instead of providing a URL directly, you manually create a browser window and load an HTML file using the API. You also need to listen to window events to decide when to quit the application.

Electron works more like the Node.js runtime. Electron's APIs are lower level so you can use it for browser testing in place of PhantomJS.

  1. Node Integration In NW.js, the Node integration in web pages requires patching Chromium to work, while in Electron we chose a different way to integrate the libuv loop with each platform's message loop to avoid hacking Chromium. See the node_bindings code for how that was done.

  2. JavaScript Contexts If you are an experienced NW.js user, you should be familiar with the concept of Node context and web context. These concepts were invented because of how NW.js was implemented.

By using the multi-context feature of Node, Electron doesn't introduce a new JavaScript context in web pages.

Note: NW.js has optionally supported multi-context since 0.13.

  1. Legacy Support NW.js still offers a "legacy release" that supports Windows XP. It doesn't receive security updates.

Given that hardware manufacturers, Microsoft, Chromium, and Node.js haven't released even critical security updates for that system, we have to warn you that using Windows XP is wildly insecure and outright irresponsible.

However, we understand that requirements outside our wildest imagination may exist, so if you're looking for something like Electron that runs on Windows XP, the NW.js legacy release might be the right fit for you.

  1. Features There are numerous differences in the amount of supported features. Electron has a bigger community, more production apps using it, and a large amount of userland modules available on npm.

As an example, Electron has built-in support for automatic updates and countless tools that make the creation of installers easier. As an example in favor of NW.js, NW.js supports more Chrome.* APIs for the development of Chrome Apps.

Naturally, we believe that Electron is the better platform for polished production applications built with web technologies (like Visual Studio Code, Slack, or Facebook Messenger); however, we want to be fair to our web technology friends. If you have feature needs that Electron does not meet, you might want to try NW.js.

Keep in mind this may be biased- it is from Electron's wiki page.

Electron doesn't introduce

a new JavaScript context in web pages.

Source code protection

Electron is packaging its applications with asar, which contains the applications' unprotected source code. This makes it possible for application 1 to extract application 2 and inject vulnerable scripts, without the user knowing it. You can checkout this project on GitHub to see an example of how to manipulate the Slack app for an example. As for now, the Electron team don't have any plans to implement support for source code protection.

NW.js has built in support for compiling your source code to protected binaries.

lanye74
  • 40
  • 10
max collomb
  • 872
  • 7
  • 3
  • 3
    Now node-webkit is renamed to NW – Marwen Trabelsi Jul 01 '15 at 00:32
  • 74
    This could be slightly biased towards Electron as this article came from Electron's repo. – gbmhunter Jul 16 '15 at 06:32
  • 7
    nw.js can run Chrome apps out-of-the-box. That is valuable to the many programmers whose apps on Chrome Webstore will soon be orphaned. – marlar Mar 05 '17 at 14:05
  • 18
    I actually recently tried using both, and I wrote a [blog post](http://my2iu.blogspot.com/2017/06/nwjs-vs-electron.html) about it. I found that nw.js is actually simpler and easier to use than Electron. It's fairly easy to just take some web pages and drop them into nw.js and go. Electron is messier to setup and their multi-process design means you have to jump through hoops even to do straight-forward stuff. Electron has a much, much richer platform integration API though, allowing you to use native Mac/Windows/Linux features more extensively in your application. – Ming-Yee Iu Jun 07 '17 at 19:31
  • 3
    I also have found NW.js browser first with Node.js added design much saner and easier to work than Electron's approach of Node.js with browser support bolted on top. With NW.js I am coding for the browser, with Electron I am coding for Node.js. – Daniel Sokolowski Mar 30 '18 at 21:35