Description
tl;dr: We should decide how non-JavaScript "declarative script types" should handle removal, insertion after previously being prepared/executed, and in the case of inline scripts, dynamic modification of text content. Establishing a framework for this will help make sure we consciously choose good author, vendor and spec author ergonomics that are as consistent as possible.
Recently a few efforts have been reusing the <script> tag to insert JSON-based declarative syntax into HTML documents:
In addition to these the HTML spec already mentions that <script>
elements can be used as a data block for author-specific purposes.
This allows these features to have an extensible syntax in a format familiar to web developers, with existing tooling, while benefiting from the existing special HTML parser behavior for <script>, notably treating its contents as character data and not constructing child elements. (Not without hazards, notably around when HTML comment syntax occurs midway through script text.)
Some options include:
- one-shot (removal ends the effect of the declaration, and a new
<script>
element must be used to reinstate it) - frozen (contents frozen at prepare/execute time, can be removed and reintroduced with removal and reinsertion of the same element)
- dynamic (broadly try to reflect changes including to the text content analogously to
<style>
)
Obviously the scripting section is both complex and security sensitive, and the observable behavior of JavaScript types must not be modified.
Longer document with some prior discussion and comparison.