Disable image loading


I’m trying to use Electron to render some HTML, but don’t need to load images. Is there some way I can disable image loading?

I saw the images option, but either that doesn’t work or I’m misunderstanding the purpose of it (not entirely sure what “image support” in the docs refers to).

Thanks in advance for any help you can offer.


You can go through and strip all img elements from the source.


I don’t want to modify the source HTML in any way. I just want to save the CPU cycles and bandwidth of loading images for this particular operation.


I should have been more specific. Run a JS script at the beginning that does a DOM search for instances of img and deletes each of them. Your script will start running when Electron reaches it (well before it gets to any of the images, in computer terms) and the page will be displayed as if there were no images at all.


Look at WebRequest.onBeforeRequest via the BrowserWindow session.
You can cancel anything that looks like an image request.


Presuming you understand how to use BrowserWindow, this works:

mainWindow = new BrowserWindow({width: 1024, height: 768, webPreferences: { nodeIntegration: true,images: false }});

The full range of webPreferences doesn’t appear to be supported in a <webview> yet