我已经浏览了AOT和JIT的定义,但是没有得到,在实时情况下我们会使用每种方法。
最佳答案
即时生产
Just-in-Time (JIT) is a type of compilation that compiles your app in the browser at runtime. JIT compilation is the default when you run the ng build (build only) or ng serve (build and serve locally) CLI commands.
AOT
Ahead-of-Time (AOT) is a type of compilation that compiles your app at build time
使用 AOT 的好处
- 更快的渲染:浏览器下载预编译版本 应用程序。所以它可以立即渲染应用程序 无需编译应用程序。
- 更少的异步请求:它是内联的 应用程序内的外部 HTML 模板和 CSS 样式表 javascript 消除了单独的 ajax 请求。
- 较小的 Angular 框架下载大小:不需要下载 Angular 编译器。因此,它大大减少了应用程序的负载。
- 更早检测模板错误:检测并报告模板绑定(bind) 构建步骤本身期间的错误
- 更好的安全性:它可以编译 HTML 模板和组件转换为 JavaScript。所以不会有任何 注入(inject)攻击。
关于javascript - 实时什么时候我们会用到AOT和JIT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56653280/