Just-in-Time (JiT) vs Ahead-of-Time (AoT) compilation in Angular

前端 未结 8 736
难免孤独
难免孤独 2020-12-04 05:50

I was referring this documentation and came across the compilation concept. One can use either JIT or AOT compilation. However, I found it very brief and need to know follow

8条回答
  •  难免孤独
    2020-12-04 06:17

    At the end fo the day, AOT(Ahead-of-Time) and JIT(Just-in-Time) do the same things. They both compile your Angular code so it can run in a native environment (aka the browser). The key difference is when the compilation happens. With AOT, your code is compiled before App downloaded in Browser. With JIT, your code is compiled at runtime in the browser.

    Here is comparison:

    Benefits of AOT:

    • Faster startup as Parsing and Compilation doesn’t happen in the Browser.
    • Templates gets checked during development(which means all the errors which we see in the javascript console in the running apps otherwise will then be thrown in our build process).
    • Smaller File Size as unused Features can be stripped out and the Compiler itself isn’t shipped.

提交回复
热议问题