I would like to use JavaScript tags inside HTML files in Electron.
I know I can use code like this in main.js:
webPreferences: { preload: path.join(__dirname, "preload.js"), },
And then import this script in HTML files like this:
<script>alert("This works!")</script>
But why can't I just use JavaScript like this inside HTML files:
alert("Why won't this work?");
There is a default meta tag in HTML when I follow Electron's quick start guide:
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'" />
And this I guess disables executing inline JavaScript.
So my question is, is it bad practice to use inline JavaScript like this in Electron? Should this be avoided?
<script></script>tags?<script>tags, then there is probably a script that is parsing your code.'unsafe-inline'was required in the CSP to allow<script></script>. developer.mozilla.org/en-US/docs/Web/HTTP/Headers/…