When a script for some custom language appears in a webpage how are these scripts executed?
<script type='text/mighty-mouse'>
// logic expressed in mighty mouse language
</script>
I would guess it would be something like this:
- Mighty Mouse interpreter queries the page on load for mighty-mouse scripts.
- The interpreter parses the script using standard lexing/compilation strategies and transpiles to JavaScript.
- The resulting JavaScript is dynamically injected into a standard script tag on the page, perhaps even eliminating the original mighty-mouse tag.
(I realize that we could have transcompiled before runtime to avoid having to load our interpreter.)
Is this an accurate and complete understanding?
Note: The exact processing details for these attributes are, for mostly historical reasons, somewhat non-trivial, involving a number of aspects of HTML. The implementation requirements are therefore by necessity scattered throughout the specification. The algorithms below (in this section) describe the core of this processing, but these algorithms reference and are referenced by the parsing rules for script start and end tags in HTML, in foreign content....