- Switching to Angular(Third Edition)
- Minko Gechev
- 315字
- 2021-07-02 15:23:31
Change detection
In the web workers section, we already mentioned the opportunity to run the digest loop in the context of a different thread, instantiated as web worker. However, the implementation of the digest loop in AngularJS is not quite as memory-efficient and prevents the JavaScript virtual machine from doing further code optimizations, which allows for significant performance improvements. One such optimization is the inline caching (http://mrale.ph/blog/2012/06/03/explaining-js-vms-in-js-inline-caches.html).
The Angular team did a lot of research in order to discover different ways the performance and efficiency of the change detection could be improved. This led to the development of a brand new change detection mechanism.
As a result, Angular performs change detection in code that the framework directly generates from the templates of the components; the code is generated by the Angular compiler. The Angular compiler is a module of the framework which can process an Angular application, after that perform different optimizations on top of it, and in the end generate code that will perform much better than the source code that we have written.
There are two built-in code generation (also known as compilation) strategies:
- Just-in-time (JIT) compilation: At runtime, Angular generates code that performs change detection on the entire application. The generated code is optimized for the JavaScript virtual machine, which provides a great performance boost.
- Ahead-of-time (AOT) compilation: This is similar to JIT, with the difference that the code is being generated as part of the application's build process. It can be used for speeding the rendering up by not performing the compilation in the browser and also in environments that disallow eval(), such as ones with strict Content-Security-Policy (CSP) and Chrome extensions. We will discuss it further in the next sections of the book.
We will take a look at the new change detection mechanism and how we can configure it in Chapter 5, Getting Started with Angular Components and Directives.
- Flask Blueprints
- Spring Cloud Alibaba微服務架構設計與開發實戰
- Visual FoxPro程序設計教程(第3版)
- 軟件項目管理(第2版)
- Python數據可視化:基于Bokeh的可視化繪圖
- Windows系統管理與服務配置
- 無代碼編程:用云表搭建企業數字化管理平臺
- PaaS程序設計
- PHP+MySQL網站開發技術項目式教程(第2版)
- Python從入門到精通(精粹版)
- Rust Cookbook
- Windows Server 2012 Unified Remote Access Planning and Deployment
- 匯編語言程序設計(第3版)
- ASP.NET 3.5程序設計與項目實踐
- Python時間序列預測