Pavel L
Pavel L

Reputation: 2047

Does using typescript hints the browser to compile scripts to byte code sooner than vanilla JS?

as I may know, browser has a JIT mode in which the JavaScript engine monitors the code as it runs. If a section of code (i.e. some heavy loop) is used enough times, the engine will attempt to compile that section into some "byte code" so that it can bypass the JS engine and use the lower-level system methods instead, which are much faster.

But, engine needs to monitor all code several times before it gets compiled because of dynamic nature of JS.

so the question is: will using Typescript eliminate these "several times" of checking, compared to using vanilla js, because TS compiler will do that earlier in compile time?

I do not consider here the benefits of TS type checking or its another cool stuff, just only this particular case.

Thanks

Upvotes: 0

Views: 159

Answers (1)

ahz
ahz

Reputation: 950

As far as I can tell TypeScript compiler does nothing for improving runtime performance. Main target of the compiler is to type check and then basically remove types to produce "vanilla" JS.

Upvotes: 1

Related Questions