1

If the javascript source code is not changed (say, loaded from the browser cache from the 2nd time), will browser/JS engine re-JIT compile the same javascript code or it will reuse the previously persisted/cached compilation results? I understand this may be browser/JS engine specific. But if all browsers/JS engines are not doing this, which may bring additional performance improvement IMHO, there must be some reasons... security or ?

Ming Zhu
  • 192
  • 1
  • 11
  • This may depend on the browser implementation, not specifically to javascript. – Ibu Mar 10 '17 at 23:03
  • Agree... anybody knows the behavior of IE/Edge/Safari/Chrome/Firefox? – Ming Zhu Mar 10 '17 at 23:24
  • In theory the v8 engine (the one used in Chrome) is capable to do this: [V8 JavaScript Engine: Code caching](https://v8project.blogspot.de/2015/07/code-caching.html). But I don't know how it is currently implemented. Based on the comments chrome cached it 2015, so I would guess it is still the case today. – t.niese Mar 13 '17 at 18:38
  • Thanks for the very concrete information. – Ming Zhu Mar 13 '17 at 18:41
  • Possible duplicate of [Do browsers parse javascript on every page load?](http://stackoverflow.com/questions/1096907/do-browsers-parse-javascript-on-every-page-load) – t.niese Mar 13 '17 at 18:45
  • I know the last updated of the linked question is from 2015, so I guess many things happened since then, but I think it should answer your question even if some techniques might be outdated and replaced in current versions of the browsers. – t.niese Mar 13 '17 at 18:47
  • Thanks again for the link to http://stackoverflow.com/questions/1096907/do-browsers-parse-javascript-on-every-page-load. I think the original question is to ask if the parsing result (syntax tree) is cached, while my question is more about the next step, if the JIT-compiling result is persisted (a next level cache). However, one of the answer really provides a lot of useful information. – Ming Zhu Mar 13 '17 at 21:12

0 Answers0