How to disable JavaScript execution of a webview in Electron on the fly?


I’m working on an Electron project that requires toggling the JS execution switch through WebPreferences of a webview.

Specifically, I have <webview id='example' src="" style="width:640px; height:480px" webpreferences="javascript=yes"></webview> and want to make the "javascript" attribute of webpreferences to false during the loading of this webview.

Does Electron provide anything like setWebPreferences()? If not, is there a workaround? I went through the documentation but found nothing.

Any help is appreciated!