That suggests a new kind of WYSIWYG editor. It only does declarative HTML/CSS, no Javascript. Maybe it edits the DOM, not the source. When you save to a file, the HTML and CSS are generated. Maybe use Webkit to do the rendering.
If you want any Javascript, it has to be in a separate .js file, not mixed in with the document.
The power of CSS has increased to the point that you don't really need Javascript for layout any more.[1] So WYSIWYG tools could work again. Probably faster.
[1] https://codingstella.com/15-advanced-web-development-techniq...