There has been some hype recently regarding the JS0 & JSSugar proposal. In short, it suggests that browsers should fork the current version of JavaScript to create JS0, which will generally aim to avoid adding new features, and instead develop JSSugar as a new, complimentary standard for implementation by (compliant) transpilers, so you would need a transpiler to access the full JavaScript language (JS0 and JSSugar).
I’d like to propose an alternative, which instead standardizes an IR (intermediate representation) that can efficiently represent a subset of JavaScript.
The IR would contain similar information to what you would find in an AST. However, ASTs tend to be big, and JSON isn’t great for serializing large trees, so we would need a binary file-format, similar to Wasm.
The IR would only include the minimum amount of information required to run the program and generate exceptions.
The browser wouldn’t need to recreate the source, as any lexical information (line numbers, column numbers, token strings etc) are taken from the source language, and the IR would include a source URL, so the browser would have everything it needs to pull up the source file and highlight the error (without any sourcemaps).
A lot of the lexical information could be omitted from the IR. For example, if we store the token lengths, we don’t need the token strings, and we could use an increment-line-number instruction, and omit the line numbers as well.
We can entirely omit lexical information for tokens that will never be the target of an exception, whether generally (due to JavaScript semantics) or in a specific instance (based on static analysis of the source language by its compiler).
There are also general optimizations that would apply here, such as using relative offsets to keep the numbers low, then LEB128 encoding them.
The IR would not support every JavaScript feature, instead aiming at a subset that makes sense as a target for transpilers. In future, it could add features that only makes sense for the IR (without corresponding JavaScript syntax), for example, statically typed functions.
An IR would provide a much nicer target for languages that (currently) transpile to JavaScript, regardless of which source language they start from. They would not require parsing (again), and could be permitted to supply extra information that allows the compiled IR to perform better.
If we assume Google are correct (Vanilla JS is passé, and only really used by “hobbyists”), and we imagine that transpilers had a decent IR they could target, then web development would naturally migrate to using JSIR transpilers and languages. The issues JS0 & JSSugar attempt to address would be resolved, and we’d have much wider scope for improving the Web over time (filling in the gap between JavaScript and WebAssembly).