I would like to use WebContents.insertCSS()
as soon as the DOM is ready.
I tried using WebContents.on('did-finish-load')
, but you can see the page being loaded before the CSS is applied.
My workaround is to have the following in a preload
JS file:
document.addEventListener('DOMContentLoaded', function () {
ipc.send('dom-ready');
});
and listen to the IPC event in the main renderer.
But it would be a lot nicer to have an event for this.
How does one use this? Id like to add CSS for the whole app.
@kylebrowning Like you should always do before asking, read the docs.
@sindresorhus Yeah I've gone over that I should have been more clear. Id like to add a whole file, not just some string. Which is unrelated to this ticket.