Hacker News new | past | comments | ask | show | jobs | submit login

Am I correct in understanding that one can implement new script language types in Javascript?



You 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.


OK, so then your language implementation walks the DOM for script tags with the required type and compiles them.

That's a pretty cool technique.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: