Skip to content
Advertisement

Import jQuery with contextBridge

I’m trying to use contextBridge in Electron, but I keep getting an error when I try to require('jQuery') in preload.js. Here is my preload.js:

JavaScript

As soon as I put require('jQuery'), I get this error:

enter image description here

I want to import APIs like this since it improves security and contextIsolation will be enabled by default in later versions of Electron.

Advertisement

Answer

I have no idea if this is secure or not, but I just imported jQuery from index.html:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement