4 ms·
They pre-process the source. You can embed `text/jsx` scripts in your code.
by nakkiel 13y ago
They pre-process the source. You can embed `text/jsx` scripts in your code.
- drgath 13y ago"Pre-process" isn't quite accurate. To me that implies processing before serving, but it appears JSX is processed in the browser by a transpiler weighing in at 300k (uncompressed). http://fb.me/JSXTransformer-0.3.0.js http://fb.me/JSXTransformer-0.3.0.js
- jlogsdon 13y agoYes, but the code is still pre-processed before it is executed by anywhere. edit: The fact that the pre-processing library is 300kb uncompressed is a pretty huge deterrent.
- simonw 13y agoPresumably if you run the pre-processer as part of your deploy (the jsx node.js command-line tool) you don't have to ship the pre-processing library to the client.
- peterhunt 13y agoThis is just for making development easy. We have a prebuild step that will do this ahead of time. Just do: npm install -g react-tools and you'll have a jsx command available. We cover this towards the bottom of this page: http://facebook.github.io/react/docs/getting-started.html http://facebook.github.io/react/docs/getting-started.html
- drgath 13y agoThanks for the FYI. I'd consider swapping the order and list the offline method first, since that's the more common approach people take (I'd hope), and it's easier to grok at a glance.
- shaneos 13y agoYou can also process it offline, so you only ship standard JS. The in-browser processing is an option you can choose to use at development time if you find it quicker/simpler.
- deleted 13y ago[deleted]
- marshray 13y agoAm 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.