Ahead-of-time Compilation

What is an Ahead-of-Time compilation?

Ahead-of-Time compilation, or AoT, as it is more commonly called, is the ability that Angular has where it can convert our HTML and TypeScript into JavaScript before the browser downloads and uses this JavaScript.

This conversion is performed by the AoT compiler, which compiles our HTML and TypeScript into JavaScript files just before they are needed.


The benefit this brings is that when a user is going to access an application in the browser, they don’t have to wait for the compiler to compile all the HTML and TypeScript of the application into JavaScript.


If we have an application that has over 100 components and templates plus 50 services, this is a large amount of HTML and TypeScript that needs to be compiled before the JavaScript is ready to be downloaded by the users’ browser. This delays our application from being usable, making it appear as though the application is slow to start, which is not good for a modern web application.

Get hands-on with 1200+ tech skills courses.