JS source code is compiled to native code with the tool
nwjc , which is provided in the SDK build.
To use it:
nwjc source.js binary.bin
*.bin file is needed to be distributed with your application. You can name it whatever you want.
The arguments of the win.evalNWBin() method are similar with the
Window.eval()method, where the first parameter is the target iframe (
nullfor main frame), and the 2nd parameter is the binary code file.
Before 0.22, the compiled code runs slower than normal JS: ~30% performance according to v8bench. Other non-compiled JS source code will not be affected. In 0.22.0-beta1, this issue has been fixed. Please check our blog post: https://nwjs.io/blog/js-src-protect-perf/
The compiled code is not cross-platform nor compatible between versions of NW.js. So you’ll need to run
nwjc for each of the platforms when you package your application.