Electron: how to configure NodeJS and runtime Chrome flags

Here is how to specify Node and Chrome flags as you would do when working in Chrome or NodeJS.

appendSwitch API

Electron allows you to configure the runtime environment as well as V8 specific flags and also Chrome-related flags using command line switches.

All these switches can be configured using JavaScript in your code by using the app.commandLine.appendSwitch API before the app is ready:

This page lists every command line switch that’s available when starting Electron using electron command.

NodeJS
To specify V8 or NodeJS related options that are usually configured using the command line – like --harmony to use staged ECMAScript features – you may can pass them using the --js-flags switch:

Chrome Flags
Electron also provides a way to configure the Chrome/Chromium flags you have usually access to by typing chrome://flags in the address bar.

This has to be done in each window that is opened using the WebPreferences and enabledlinkFeaturesproperty when calling the BrowserWindow constructor.

For example, to enable the OverlayScrollbars flag, you would use the following code:

Some Chrome flags can also be disabled using the disableBlinkFeatures property.

For the complete list of features that can be enabled or disabled you can check this page.


Warpdesign.fr