Just In Time and Ahead Of Time compilation

  • In JIT compilation, the application compiles inside the browser during runtime.
    Whereas in the AOT compilation, the application compiles during the build time.
  • Done using ng-serve
  • All the ng-if and ng-for etc are compiled when the page is loaded
  • The files downloaded on the browser during JIT is higher because the JIT compiler itself is downloaded into the browser
  • The advantages of using AOT compilation are:
  • Since the application compiles before running inside the browser, the browser loads the executable code and renders the application immediately, which leads to faster rendering.
  • In AOT compilation, the compiler sends the external HTML and CSS files along with the application, eliminating separate AJAX requests for those source files, which leads to fewer ajax requests.
  • Developers can detect and handle errors during the building phase, which helps in minimizing errors.
  • The AOT compiler adds HTML and templates into the JS files before they run inside the browser.
  • Due to this, there are no extra HTML files to be read, which provide better security to the application.
  • Done using ng build –configuration=production

Leave a Comment