4 ms·
This is kind of a noob question, but do you have any idea if Javascript actually gets fully parsed on the client side every time it's used, or if the AST gets c
by 13of40 9y ago
This is kind of a noob question, but do you have any idea if Javascript actually gets fully parsed on the client side every time it's used, or if the AST gets cached? (Let's assume the "client side" is a newish version of Chrome.)
- tachyonbeam 9y agoChrome now caches compiled code: https://v8project.blogspot.ca/2015/07/code-caching.html https://v8project.blogspot.ca/2015/07/code-caching.html In addition to this, browsers do lazy parsing. They do not fully parse the bodies of functions until the functions are executed.
- Yoric 9y agoNote that "lazy parsing" means "do most of the parsing, just don't store the result". That's a consequence of the specifications of JavaScript that require all syntax errors to be thrown as early as possible. This is something that would change with the Binary AST, hence allowing much lazier parsing.
- Yoric 9y agoFirefox now caches bytecode, too. https://groups.google.com/forum/#!topic/mozilla.dev.platform/4u6EsaDC7kY https://groups.google.com/forum/#!topic/mozilla.dev.platform... Note, however, that caching bytecode solves a different problem. Caching bytecode is great for the second+ load of a website. Making initial parsing faster is great for the first load of a website since its latest update. If you consider that Facebook updates its front-end once per hour, for instance, that's a lot for some (not all) websites. Also, the size improvements may come in useful for applications written in, say, Cordova/PhoneGap.
- Yoric 9y agoI meant "several times per day".
- djeric3 9y agoChrome and Firefox both cache hot code in its compiled (bytecode) form. This proposal addresses cold code loads. Many web apps update frequently (more than once per day) making caching much less effective, and cold code much more common.