Creating Javascript Binaries For Electron

Can we create binaries from Javascript?

Can we create JS binaries for Electron?

  1. Bytenode needs access to Node.js’ V8 functions in order to read the binaries. This will work just fine for your main process and any preload scripts. But you’ll need to enable nodeIntegration for webPreferences in your BrowserWindows. Alternately, you can usually move most of your renderer Javascript into a preload script wrapped around a document.addEventListener('DOMContentLoaded') listener. You’ll also need to set contextIsolation to false, or come up with a more elegant workaround.
  2. The Bytenode Webpack Plugin will create conventional text-based Javascript “loader” files for each entry point which load the binaries. These are not compiled… but they also were not part of your original source code.
  3. There are a few known issues with Bytenode. The main one to be aware of is that asynchronous arrow functions will cause crashes when used in rendering process code. You can simply convert these to function calls, or you could code in Typescript and output ES5, or you could use the Webpack babel-loader plugin to transform your arrow functions.
  4. It looks like Electron is deprecating Node’s V8 library in the render process beginning with Electron 12. Bytenode still works for now, but we’re be keeping an eye on this.

How do I get started?

  • Electron Bytenode Example — a boilerplate “Hello World” example of an Electron app running on Bytenode, built with Webpack via Electron Forge
  • Bytenode Webpack Plugin — the Webpack plugin which makes all of this easy
  • Bytenode — the library which converts your Javascript code to binary and loads the binary files for execution at run time



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jeff Robbins

Jeff Robbins

Cofounder at @Lullabot. Executive Coach at @jjeff. Rockstar at @Orbitband.