2 ms·
Am I correct in understanding that one can implement new script language types in Javascript?
by marshray 13y ago
Am I correct in understanding that one can implement new script language types in Javascript?
- esailija 13y agoYou can do `<script type="anything-you-want"></script>`. It's just an attribute. The browser will not run any code in the tag because the `type`-attribute is invalid now. The next step is to create a compiler for your `anything-you-want` language. That means it transforms the textual contents of the script tag into a string of javascript, and then calls `eval` on the string.
- marshray 13y agoOK, so then your language implementation walks the DOM for script tags with the required type and compiles them. That's a pretty cool technique.