A quick guide to Angular

Ayaz Qureshi
3 min readJun 11, 2022

--

Web developers utilised VanillaJS and jQuery to create dynamic websites back in the day, but the code became increasingly difficult to maintain as the logic of the website grew. Developers had to put in extra effort to keep the app’s separation of concerns for applications that used complicated logic. Furthermore, jQuery lacked the ability to handle data across many views.

Photo by Uday Mittal on Unsplash

Client-side frameworks such as Angular came into being to address the aforementioned issues, making life easier for developers by handling separation of responsibilities and separating code into smaller chunks of information (in the case of Angular, called Components).

Photo by Ferenc Almasi on Unsplash

Client-side frameworks enable complex web apps such as Single-Page-Application to be created. It’s not that VanillaJS can’t be used to build SPAs, but it makes the process slower.

But what makes Angular stand out from other frameworks?

Out-of-the-box features — Angular comes with a variety of pre-installed features such as routing, state management, the rxjs library, and http services. This means that the above-mentioned characteristics do not have to be sought separately. All of them come with angular.

Declarative UI — Angular renders an application’s UI using HTML. HTML is a declarative language that is far more user-friendly than JavaScript.

Google’s Long-Term Support for Angular — Google has declared its long-term support for Angular. This indicates that Google intends to continue with Angular and expand its ecosystem.

What exactly is an AOT compilation?

Every Angular application has components and templates that are incomprehensible to the browser. As a result, all Angular applications must first be compiled before being executed in the browser.

Compilation comes in two flavours in Angular:
— Compilation JIT (Just-in-Time)
— Compilation AOT (Ahead-of-Time)

The programme compiles in the browser during runtime with JIT compilation. The programme compiles during the build time in the AOT compilation.

What are some of the benefits of AOT?

— The browser loads the executable code and renders the application immediately since the application compiles before executing inside the browser, resulting in faster rendering.
— The compiler delivers the external HTML and CSS files along with the application in AOT compilation, avoiding the need for separate AJAX calls for those source files, resulting in fewer ajax queries.
— During the construction phase, developers can discover and handle mistakes, which helps to reduce errors.
— Before the JS files execute inside the browser, the AOT compiler adds HTML and templates to them. As a result, there are no additional HTML files to read, which improves the application’s security.

Client-side rendering is the default for Angular applications.

Is it possible to create an Angular application that renders on the server?
Yes, Angular has a technology called Angular Universal that can be used to render server-side applications.

The following are some of the benefits of adopting Angular Universal:

— First-time users can see a preview of the app right away. This contributes to a better user experience.
— Because many search engines need sites to be written in plain HTML, Universal can ensure that your content is found by every search engine, resulting in improved SEO.
— Because rendered pages are available to the browser sooner, any server-side rendered application loads faster.

--

--

Ayaz Qureshi
Ayaz Qureshi

Written by Ayaz Qureshi

I write about startups, entrepreneurship mindset, strategies and app development.