Sunday, June 27, 2021

Angular 10 Available With Typescript 3.9, TSLIB 2.0, New Features & Updates

 

Angular 10


Angular version 10, has been released on the 24th of June, 2020 but with the beta version this time. This can mean that we are nearing the final release of the newest version of the google-developed, typescript based framework. This is a major release however this latest angular version will majorly focus on the ecosystem and quality tools rather than introducing new features. This could mean that we are going to witness a lot of deprecation and upgrades.

The angular team launched its version 9 in February that has paved the way for the new version. Ever since the last release, everyone has been keeping close tabs for the launch of the new release. Angular 9.1 that was released early in the month of April, promises some of the minor updates from version 9. While the version 9 highlights the default IVY renderer and internationalization, angular 9.1, includes the support for TypeScript 3.8, performance improvements, and a long list of bug fixes.

Angular 10 features new date range picker in the Angular Material UI component library and warnings for CommonJS imports. The speed with which Angular releases picking up is good enough to convince any AngularJS Development Company to keep up with the latest upgrades. 

In this blog we are determined to highlight the features of Angular 10 and the effect it has on the entire angular ecosystem. Let's dive into what's new in Angular 10.

Angular 10 - Features & Updates

Angular 10


Language Service

The language-service-specific compiler enables multiple typecheck files by using the project interface which creates ScriptInfos as necessary. Autocompletion is also seemed to have been removed from HTML entities, such as &, <, etc., so as to safeguard the inhouse core functionality of Angular LS, which holds questionable value and a performance cost.

New Default Browser Configuration

Browser configuration for new projects have been updated to outdo older and less used browsers. This includes the side effect of disabling ES5 builds by default for new projects. One simply has to add the required browsers in the .browserslist RC file.to enable ES5 builds and differential loading for browsers.

Compiler Update

In the latest angular version, a compiler interface has been added in order to wrap the actual ngtsc compiler. Angular version 10 has added name spans for property reads and method calls. In addition to this Dependency information, ng-content selectors, Angular Language Service have also been added to the metadata. It also welcomes the propagation of the precise cost span in an ExpressionBinding of a micro syntax expression to ParsedProperty, which, in turn, might propagate the span to the template ASTs (both VE and Ivy).

Optional Stricter Settings

Angular version 10 offers a more strict project setup in order to create a new workspace with ng new.

ng new --strict

Once this flag is enabled, it initializes the new project with a couple of new settings that improve maintainability, assist in catching bugs well ahead in time, and permit the CLI to perform advanced optimizations on your app. Enabling this flag configures the app as side-effect free to ensure more advanced tree-shaking.

Ngcc

With this angular 10 feature, there has been an implementation of a A Program-based entry-point finder, which is designed to only process entry points that can only be reached by a program defined by a tsconfig.json file. By using this option, one can catalyze the process in places with a number of dependencies installed with relatively small numbers of entry points that are actually imported into the application. This particular feature helps manifest and reduce the file size of the entry-point.

The base path of the package and entry points need not be stored in the file, and hence Storing unnecessary empty arrays can be avoided. In the previous versions, ngcc seemed to parse the files of the entry point in order to compute dependencies. This would take a lot of time for large node modules.

Performance Improvements

One can see improvement in the performance that is achieved by reducing the size of the entry point. In addition, caching of dependencies is executed within the entry point manifest and are read from there as opposed to being computed each time. Previously, even though an entry point did not need processing, ngcc (Angular Ivy compatibility compiler) might parse the files of the entry point to compute dependencies, which might take a whole lot of time for large_node modules. The computation of basePaths has been made lazy in order to improve performance. What previously was done whenever the finder was instantiated is now only done if needed in TargetedEntryPointFinder.

Service Workers

In the previous versions of angular Vary headers might have been taken into consideration while retrieving resources from the cache, however absolutely stopping the retrieval of cached assets and main to unpredictable behavior due to inconsistent/buggy implementations in various browsers. However, in angular version 10 Vary headers are overlooked while retrieving sources from the ServiceWorker caches, which can result in sources being retrieved even when their headers are not similar. If your application needs to differentiate its responses based totally on request headers, it is important to ensure that the Angular ServiceWorker is configured to avoid caching the affected resources.

Typescript 3.9, TSLib 2.9 & TSLint v6

Angular 10 features typescript 3.9. As opposed to the previous version which supported typescript 3.6, 3.7 and even 3.8. Typescript is a language that builds on JavaScript by adding syntax for type declarations and annotations which is used by the TypeScript compiler to type-check our code. This in turn clean readable JavaScript that runs on lots of different runtimes.

Typescript helps save the files with its rich editing functionality across editors. With Typescript 3.9 the team has worked on performance, polish, and stability. Apart from error-checking, this version powers things like completions, quick fixes and speeding up the compiler and editing experience.

Let's have a look at some of the exciting features of Typescript 3.9:

  1. TSlib, the runtime library for TypeScript consisting of helper functions, has now been updated to TSlib 2.0. Along with this there is an upgrade on the TSLint static analysis tool for TypeScript to version 6.
  2. The // @ts-expect-error comments before a code line as a prefix, so that the TypeScript won’t report the error. Typescript will show ‘Unused '@ts-expect-error' directive if there isn't any error.
  3. Angular 10 also has deprecated the inclusion of ESM5 or FESM5 bundles which saves 119MB of download and install time while running yarn or npm install for Angular packages and libraries. With angular version 10 TypeScript automatically detects the types of imports that are used to keep any type of files style clean. Any downleveling to support ES5 in this version will be done at the end of the build process.
  4. Complications with functions like ‘Promise.all’ and ‘Promise.race’ have been sabotaged and the 3.7 version has now been fixed.
  5.  With the latest versionTypeScript provides a quick fix solution to add missing return statements in cases where one might forget to return the value from a function at the end of that function.
  6. "}" and ">" are now considered invalid JSX text characters with the typescript new version.

Localization

One of the best features of Angular 10 is that the latest angular version supports for merging of multiple translation documents which could only load one file in the previous versions.Now customers can specify a couple of documents in keeping with locale, and the translations from each of these documents can be merged together by means of a message ID. In practice, this means you need to put the documents so as of most essential first, with fallback translations later.

Router

The CanLoad guard now can go back Urltree in angular version 10. A CanLoad guard returning Urltree cancels the cutting-edge navigation and helps to redirect. This matches current behavior to the available CanActivate guards that are also apparently added. This however doesn’t affect the preloading. Also, any routes with a CanLoad guard won’t be preloaded, and the guards will not be completed as a part of preloading.

hire angular developers


Deprecation

Angular 10 features typescript 3.9. As opposed to the previous version which supported typescript 3.6, 3.7 and even 3.8. Angular 10 also has deprecated the inclusion of ESM5 or FESM5 bundles which saves 119MB of download and install time while running yarn or npm install for Angular packages and libraries. any down leveling to support ES5 in this version will be done at the end of the build process.

We will also see a deprecation of older browsers including IE 9, 10, and Internet Explorer Mobile that are Based on heavy consultation with the community.

Breaking Changes

Logic is updated pertaining to formatting day periods that cross midnight, in order to match the time within a day period that extends past midnight. Applications that are using either formatDate() or DatePipe or the b and B format codes are likely to be affected by this change.

Another point under this section is that any resolver that returns EMPTY will happen to cancel navigation. In order to enable any navigation, developers will have to update the resolvers to update some vale, such as default!Empty.

Angular NPM in version 10 does not contain positive jsdoc remarks to assist the Closure Compiler’s advanced optimizations. Support for Closure Compiler in applications has been experimental and damaged for a few times. For people who will make use of Closure Compiler is likely higher off absorbing Angular applications built from sources directly rather than ingesting variations posted on NPM. As a transient workaround, customers can not forget the usage of their present-day build pipeline with Closure flag --compilation_level=SIMPLE. This flag will ensure that the build pipeline produces buildable, runnable artifacts, at a cost of accelerated payload size because of advanced optimizations being disabled.

Core

Among all the features of angular 10 , this is quite an interesting one. All the warnings will be now logged in as errors. This will obviously not break an app, but it might game up the tools that expect nothing to be logged via console.error. Generic is made to be mandatory for ModuleWithProviders in this new version, in order to work with the Ivy compilation and rendering pipeline. This ensures that if a developer is using View Engine, no build error will be issued. In this case, ngcc won't be able to help and the migration might just cover the application code.

Bug Fixes

With this Angular 10 version, there have been a number of bug fixes, this includes the compiler avoiding undefined expressions in a holey array and the core avoiding a migration error while a nonexistent symbol is imported. Another bug fix ensures proper identification of modules affected by overrides in TestBed.

Converting pre-Ivy code

All the pre-Ivy dependencies from npm should be transformed to Ivy dependencies, which is supposed to take place as a precursor to running ngtsc at the application. Further all the future compilation and linking operations ought to be made in the direction of transforming versions of the dependencies.

How to update to version 10

In order to upgrade to Angular version 10, one can use this command:

ng update @angular/cli @angular/core

For more information about this update, read: Updating to version 10 guide.

Conclusion

Ideally, the Angular team releases two versions in a year. The earlier version, version 9 was released just four months ago, and hence the team is already looking to release Angular 11 in the fall. For people looking out to hire angular developers for their projects, it is important to look out for a reliable and trusted partner to team with, which will ensure a smoother path ahead.

Optimizing AngularJS Single-Page Applications for Googlebot Crawlers

 It’s almost certain that you’ve encountered AngularJS on the web somewhere, even if you weren’t aware of it at the time. Here’s a list of just a few sites using Angular:

  • Upwork.com
  • Freelancer.com
  • Udemy.com
  • Youtube.com

Any of those look familiar? If so, it’s because AngularJS is taking over the Internet. There’s a good reason for that: Angular- and other React-style frameworks make for a better user and developer experience on a site. For background, AngularJS and ReactJS are part of a web design movement called single-page applications, or SPAs. While a traditional website loads each individual page as the user navigates the site, including calls to the server and cache, loading resources, and rendering the page, SPAs cut out much of the back-end activity by loading the entire site when a user first lands on a page. Instead of loading a new page each time you click on a link, the site dynamically updates a single HTML page as the user interacts with the site.

image001.png

Image c/o Microsoft

Why is this movement taking over the Internet? With SPAs, users are treated to a screaming fast site through which they can navigate almost instantaneously, while developers have a template that allows them to customize, test, and optimize pages seamlessly and efficiently. AngularJS and ReactJS use advanced Javascript templates to render the site, which means the HTML/CSS page speed overhead is almost nothing. All site activity runs behind the scenes, out of view of the user.

Unfortunately, anyone who’s tried performing SEO on an Angular or React site knows that the site activity is hidden from more than just site visitors: it’s also hidden from web crawlers. Crawlers like Googlebot rely heavily on HTML/CSS data to render and interpret the content on a site. When that HTML content is hidden behind website scripts, crawlers have no website content to index and serve in search results.

Of course, Google claims they can crawl Javascript (and SEOs have tested and supported this claim), but even if that is true, Googlebot still struggles to crawl sites built on a SPA framework. One of the first issues we encountered when a client first approached us with an Angular site was that nothing beyond the homepage was appearing in the SERPs. ScreamingFrog crawls uncovered the homepage and a handful of other Javascript resources, and that was it.

SF Javascript.png

Another common issue is recording Google Analytics data. Think about it: Analytics data is tracked by recording pageviews every time a user navigates to a page. How can you track site analytics when there’s no HTML response to trigger a pageview?

After working with several clients on their SPA websites, we’ve developed a process for performing SEO on those sites. By using this process, we’ve not only enabled SPA sites to be indexed by search engines, but even to rank on the first page for keywords.

5-step solution to SEO for AngularJS

  1. Make a list of all pages on the site
  2. Install Prerender
  3. “Fetch as Google”
  4. Configure Analytics
  5. Recrawl the site

1) Make a list of all pages on your site

If this sounds like a long and tedious process, that’s because it definitely can be. For some sites, this will be as easy as exporting the XML sitemap for the site. For other sites, especially those with hundreds or thousands of pages, creating a comprehensive list of all the pages on the site can take hours or days. However, I cannot emphasize enough how helpful this step has been for us. Having an index of all pages on the site gives you a guide to reference and consult as you work on getting your site indexed. It’s almost impossible to predict every issue that you’re going to encounter with an SPA, and if you don’t have an all-inclusive list of content to reference throughout your SEO optimization, it’s highly likely you’ll leave some part of the site un-indexed by search engines inadvertently.

One solution that might enable you to streamline this process is to divide content into directories instead of individual pages. For example, if you know that you have a list of storeroom pages, include your /storeroom/ directory and make a note of how many pages that includes. Or if you have an e-commerce site, make a note of how many products you have in each shopping category and compile your list that way (though if you have an e-commerce site, I hope for your own sake you have a master list of products somewhere). Regardless of what you do to make this step less time-consuming, make sure you have a full list before continuing to step 2.

2) Install Prerender

Prerender is going to be your best friend when performing SEO for SPAs. Prerender is a service that will render your website in a virtual browser, then serve the static HTML content to web crawlers. From an SEO standpoint, this is as good of a solution as you can hope for: users still get the fast, dynamic SPA experience while search engine crawlers can identify indexable content for search results.

Prerender’s pricing varies based on the size of your site and the freshness of the cache served to Google. Smaller sites (up to 250 pages) can use Prerender for free, while larger sites (or sites that update constantly) may need to pay as much as $200+/month. However, having an indexable version of your site that enables you to attract customers through organic search is invaluable. This is where that list you compiled in step 1 comes into play: if you can prioritize what sections of your site need to be served to search engines, or with what frequency, you may be able to save a little bit of money each month while still achieving SEO progress.

3) "Fetch as Google"

Within Google Search Console is an incredibly useful feature called “Fetch as Google.” “Fetch as Google” allows you to enter a URL from your site and fetch it as Googlebot would during a crawl. “Fetch” returns the HTTP response from the page, which includes a full download of the page source code as Googlebot sees it. “Fetch and Render” will return the HTTP response and will also provide a screenshot of the page as Googlebot saw it and as a site visitor would see it.

This has powerful applications for AngularJS sites. Even with Prerender installed, you may find that Google is still only partially displaying your website, or it may be omitting key features of your site that are helpful to users. Plugging the URL into “Fetch as Google” will let you review how your site appears to search engines and what further steps you may need to take to optimize your keyword rankings. Additionally, after requesting a “Fetch” or “Fetch and Render,” you have the option to “Request Indexing” for that page, which can be handy catalyst for getting your site to appear in search results.

4) Configure Google Analytics (or Google Tag Manager)

As I mentioned above, SPAs can have serious trouble with recording Google Analytics data since they don’t track pageviews the way a standard website does. Instead of the traditional Google Analytics tracking code, you’ll need to install Analytics through some kind of alternative method.

One method that works well is to use the Angulartics plugin. Angulartics replaces standard pageview events with virtual pageview tracking, which tracks the entire user navigation across your application. Since SPAs dynamically load HTML content, these virtual pageviews are recorded based on user interactions with the site, which ultimately tracks the same user behavior as you would through traditional Analytics. Other people have found success using Google Tag Manager “History Change” triggers or other innovative methods, which are perfectly acceptable implementations. As long as your Google Analytics tracking records user interactions instead of conventional pageviews, your Analytics configuration should suffice.

5) Recrawl the site

After working through steps 1–4, you’re going to want to crawl the site yourself to find those errors that not even Googlebot was anticipating. One issue we discovered early with a client was that after installing Prerender, our crawlers were still running into a spider trap:

As you can probably tell, there were not actually 150,000 pages on that particular site. Our crawlers just found a recursive loop that kept generating longer and longer URL strings for the site content. This is something we would not have found in Google Search Console or Analytics. SPAs are notorious for causing tedious, inexplicable issues that you’ll only uncover by crawling the site yourself. Even if you follow the steps above and take as many precautions as possible, I can still almost guarantee you will come across a unique issue that can only be diagnosed through a crawl.

If you’ve come across any of these unique issues, let me know in the comments! I’d love to hear what other issues people have encountered with SPAs.

Results

As I mentioned earlier in the article, the process outlined above has enabled us to not only get client sites indexed, but even to get those sites ranking on first page for various keywords. Here’s an example of the keyword progress we made for one client with an AngularJS site:

Also, the organic traffic growth for that client over the course of seven months:

All of this goes to show that although SEO for SPAs can be tedious, laborious, and troublesome, it is not impossible. Follow the steps above, and you can have SEO success with your single-page app website.

About JR Ridley —

What’s new in Angular 10?

 

Have you been a strict adherent of Angular, keeping a tab on every single update and version?

So, you are in the right place, as the article will acquaint you with the latest release of Angular i.e. Angular 10 as well as its top highlights. According to the survey conducted by Statista, JavaScript with 68% of votes, is the most popular programming language among the developers, and Angular, being one of the most strong variants of JavaScript, is gaining immense popularity as well. The reason behind such popularity is the advantages offered by Angular that are Cross-Platform Development, impeccable speed and performance, amazing tooling, and a humongous community.

Angular helps to create an intuitive as well as dynamic SPAs (Single Page Application), using Typescript along with the HTML/CSS to code the Application which is compiled to JavaScript. Not only this, Angular comes with some of the unique features, making it stand out among other JavaScript Frameworks, such as:

Dependency Injection(DI)
Angular comes with its own DI, providing the declared dependencies, that are the objects and services from the external sources, at the time of class instantiation and making the application flexible, efficient, testable, robust, and maintainable.

Directives
Angular facilitates the programmer with a modular programming approach through the element called Directives, making the code more structured and clean. A Directive is a reusable component that embodies the functional and behavioural properties of a component, allowing to keep a record of the changes in an HTML code at one place rather than tracking it throughout the script.

Typescript
Angular uses a more advanced form of JavaScript – TypeScript, also called Superset of JavaScript. Though the language is a bit complex than JavaScipt, it promises higher security, speed, and better performance offered through early detection of errors.

POJO
Despite being based on a new language i.e. Typescript, Angular does not force you to create any sort of additional getters or setters, rather empowers you to manipulate the Object functionalities and properties as per the requirement through the same JavaScript code. The reason behind such a facility is that the objects used in Angular are Plain Old JavaScript Object (POJO) rather than the typescript ones.

Angular is continuously evolving and with its every version, it upgrades itself with some novel and tremendous features. Let’s check out the latest features that are included in Angular 10.

Upcoming features of Angular 10

Angular has come a long way since its release in 2009, releasing numerous successful versions ranging from Angular JS to Angular 9. Its latest version Angular 10, is already on the way to get released, in fact, two of its beta version already released in April 2020, which can be downloaded from GitHub. Angular 10 is expected to be smaller than that of the previous Angular versions, including some new features along with the pre-existing features of Angular 9.

  • Improved Performance

    The Performance of the Angular 10 is definitely the highlight of this version, thanks to modifications like cache at the entry point manifest as well as the reduced size of the manifest, the performance of Angular 10 has exceeded its previous versions.

    Angular 10 facilitates the caching of the dependencies (Objects and services) at the entry point itself, making it easy to access and reducing the computation load as well as liberating from the process of loading and computing the dependencies every time when required.

  • URL Matcher returns NULL

    Angular 10 has updated the URL Matcher feature, which matches the routes against the URL. Unlike previous versions, in Angular 10, the URL matcher is allowed to return NULL.

    Track the change at GitHub.

  • Dependency Information should be added to Metadata

    According to this feature, the declaration of the class should contain information about Angular decorators used in Constructors, if used, else the value should be set to null type. The Metadata should also include the ng-content selectors which are quite helpful for tooling. These tools extract the necessary information from metadata.json manifest file and offer suggestions for directives or components that are defined in libraries.

    Track the change at GitHub.

  • Decorated Derived Classes of Undecorated Class Migration

    Earlier in the previous version of Angular, among the Base Class and Derived Class, Directives were added only to the Base Class during the Migration, which has been addressed in Angular 10. In this version, the missing logic has been added, hence, during the Class Migration, Directives are added to both Base Class as well as Derived Class, enabling the Angular Compiler to add Directive definition to the components of the Derived class.

    Track the change at GitHub.

  • Changed Service Worker(SW) Strategy

    In order to address the challenge of registration of the service workers during the long-running task or timeouts, Angular 10 has changed the Service Worker Strategy, trying to wait for the stabilization of the Application, failing which registration automatically occurs after 30 seconds.

    Track the change at GitHub.

  • Avoid Runtime Error due to the Import of Non-Existent Symbol

    This is a problem faced when a project tries to import a non-existent identifier, leading to Runtime Error, and hence Migration Fail. The reason behind this is the failure of TypeScript to compute the path from the original source to the imported source which is expected to provide the non-existent identifier. The problem has been resolved in the latest version that is Angular 10.

    Track the change at GitHub.

Take-Aways

Be an Early Bird and Walk with Us.

Technology is evolving every day and to be up-to-date, making it imperative to keep track of the changes and adapt accordingly. Using Angular for a while now, the power of the framework is not obscure anymore. With astonishing features like web components reuse, data binding, incredible tooling, and unwavering support from tech mammoths like Google, Angular has revolutionized web designing and thereby the whole Web App Development Process.

Looking up to the luminous efficacies of the previous versions of Angular as well as the new developments and bug fixes introduced in the Angular 10, it can be considered as an ideal choice for Web App Development. So, continue following the progressions and Walk with us. Hire an Angular Developer and kick start your app development process.

Angular helps to build both intuitive and dynamic SPAs, using Typescript and HTML / CSS to code the JavaScript-compiled framework.

According to Statista’s report, JavaScript is the most common programming language among developers with 68% of votes, and Angular, being one of JavaScript ‘s main variants, it is also gaining immense popularity.

Angular version 10, released June 24th, 2020 but this time with the beta edition. This may mean we are nearing the final release of the newest iteration of the typescript-based system developed by Google.

Nonetheless, this current angular edition will concentrate mainly on the environment and quality tools rather than adding new functionality. That may mean we will be seeing a lot of deprecation and updates.

Let’s take a look at the key features and value offerings for Angular 10!

This release focuses more on problem-solving. 700 problems were resolved in the process, and more than 2,000 were hit.
For a couple of years, the Angular team has been working hard on the Ivy engine and after Ivy was launched with Angular 9, the team is now able to concentrate more on problems that couldn’t be taken care of before.

Below are the latest features included in version Angular 10:-

Warnings about CommonJS import

Originally designed for server-side modules, CommonJS was not intended to reduce the production package size. Using dependencies bundled with CommonJS will lead to bigger bundles of code and slower applications.
Angular version 10 now alerts you when a CommonJS module pulls into your build.

Optional Stricter Settings

Angular version 10 provides a more rigorous project set up to build a new ng-new workspace.
ng new –strict

If this flag is activated, it initializes the new project with a few new settings that improve maintainability, help to find bugs well ahead of time, and allow the CLI to perform advanced optimizations on your application. Configuring the device as side-effect free to allow this flag to ensure more advanced tree-shaking.

New Date Range Picker

Angular 10 came with the all-new picker date set. You can use elements of both mat date picker range and mat date input range to use it.

Boost in ngcc Performance

For this angular 10 feature, an A Program-based entry-point finder has been introduced which is configured to process only entry points that can only be reached via a program defined by a tsconfig.json file.
Through using this method, one can catalyze the process in places where a number of dependencies are installed with relatively limited numbers of entry points which are actually imported into the application. 

Async Locking Timeout

The design of Async locking timeout is also possible and could include assistance in the ngcc.config.js file, modification of the delays in retry, and retry attempts in the AsyncLocker.

Removals and Corrections

The key team of Angular developers conducted a lot of deprecation and removed some of the stuff from this website. Additionally, some older browsers such as Internet Explorer Web, Internet Explorer 9, 10 were also taken out of support.

Compiler Update

In the most recent Angular 10 a compiler interface was introduced to cover the real ngtsc compiler. Angular 10 also provided name spans for calls by process and property reads. In addition to this, the metadata also included ng-content selectors, Dependence data, and Angular language support.
It also accepts the procreation of the exact cost duration in the ExpressionBinding to ParsedProperty of a micro syntax expression which, as a result, may procreate the time to the ASTs template (both Ivy and VE).

TSLint v6, TSLib 2.9, and Typescript 3.9

Angular 10 supports Typescript 3.9. In JavaScript, typescript language is created by providing syntax for annotations and type declarations used by the Typescript compiler to type-check the code of developers. It cleans readable JavaScript which runs on multiple runtimes. With its great editing efficiency, Typescript helps save files through editors. Typescript 3.9 assists the team in their work on consistency, polish, and efficiency.

Generic with Module With Providers

The use of generic keywords has become mandatory with the ModulWithProviders in Angular 10. This was added to make the ModuleWithProviders patterns work with the rendering sequence and Ivy compilation.

Bug Fixes

Most bug fixes are performed in Angular 10, which includes eliminating unaddressed examples of the range in the parser, and the errors created due to migration when the symbol does not exist. In addition, the Terser Inlining Bug was fixed in Angular 10, too.

Combining with Many Transition Files

For Angular 10 new features launching, developers can combine several files in just one go. In addition, this file transaction is done through messaging functions.

Conclusion

Technology is continually changing and becoming up-to-date, making it important to keep track of the developments and adapt accordingly. For a while now, using Angular, the power of the Framework is no longer obscure.

With incredible features such as reuse of web elements, data linking, innovative tooling, and unwavering support from tech mammoths like Google, Angular has revolutionized the whole idea of web design and web development.

9 Ways to Improve AngularJS Performance

 


Today, online businesses are greatly affected by the performance of web technologies that they use for their respective projects. Hence, it becomes necessary to dig into all of the factors that are hurting their business growth.

But there might be cases in which the incorrect use of AngularJS methods restricts your application's stance in the market, so AngularJS performance optimization becomes an important need of every AngularJS development expert. That’s why we're listing nine ways to improve AngularJS performance in this blog.

Related Reading: Top 10 Advantages of Using AngularJS

Recently, a survey was conducted by Brazilian computer scientists who found interesting facts about what causes performance problems for AngularJS programmers. There is not much information about how AngularJS performs in the real world. But research based on surveys provide some pieces of evidence for it.

The survey came up with the following results:

angular1

  • 45% voted that the source code problem that affects performance.

  • Only 8% admitted to actually making changes.

  • Some respondents blamed the architecture of AngularJS.

  • Some of them blamed unnecessary two-way binding.

After so much discussion on AngularJS performance, now it’s time to see the nine ways through which you can improve AngularJS performance.

AngularJS performance can be easily measured by its digest cycle. The digest cycle can be taken as a loop. During this cycle, Angular checks if there is any change to all the variables watched by all $scopes. If $scope.myVar is defined in a controller and marked for watching, then Angular will monitor the changes on myVar in each loop iteration.

1. Batarang Tool to Benchmark Watchers

Batarang is a great dev tool from the Angular team that lowers your debugging efforts. Although it has many new features, some of them help you profile and track the performance of your AngularJS performance. Moreover, the watch tree determines which scopes are not destroyed as it seems to be if there is any increase in the memory.

2. Use of Native JavaScript or Lodash

Lodash boosts your application performance by simply rewriting some of the basic logic instead of relying on inbuilt AngularJS methods. If Lodash is not included in your application, then you would probably need to re-write everything in native JavaScript.

3. Chrome Dev Tool Profiler to Identify Performance Bottlenecks

This one is a handy tool that gives you the option to select which profile type you want to create. Record Allocation Timeline, Take Heap Snapshot, and Record Allocation Profile are used for memory profiling. After this performance optimization, your app will fully render in less than two seconds and users can freely interact with it then.

4. Minimize Watchers

AngularJS completely revolves around its digest cycle. Whenever a digest cycle is triggered, it loops over every binding to detect model changes. The amount of time taken in each digest cycle can be reduced by reducing the number of watchers. It also reduces application memory footprints.

5. ng-if Is Better Than ng-show

The ng-show directive toggles the CSS display property on a particular element, while the ng-if directive actually removes the element from DOM and re-creates it if needed. Further, the ng-switch directive is an alternative to the ng-if with the same performance benefits.

6. Don't Use ng-repeat

This is the biggest win for any app if it is not using the ng-repeat directive, so it is advisable to avoid ng-repeat and build the HTML using JavaScript. For vocalizing applications, the use of ng-if results in the addition of unnecessary watchers. The use of the ng-bind-html directive is a better solution to get rid of this problem.

7. Use $watchCollection (Includes Third Parameter)

Using $watch with two parameters is good — but using $watch with three parameters, i.e. $watch(‘value’,function(){},true), makes Angular perform deep checking (to check every property of the object). But this could be expensive. Hence, to resolve such a performance issue, Angular provides $watchCollection(‘value’, function(){}) which acts almost alike $watch with 3rd parameter except it only checks first layer of object’s properties at low cost.

8. Use console.time for Debugging Issues

If your application is struggling with debugging issues and effecting Angular performance, then use console.time, which is a great API.

9. Debounce ng-model

You can debounce the input with ng-model. For example, to de-bounce the search input like GOOGLE, you have to use ng-model-options=”{debounce:250}”. This makes the digest cycle get triggered no more than once per 250ms due to the changes in this input model.

Development time is at a premium nowadays, so you need a comprehensive framework such as AngularJS to run your business quickly out of the box.

After researching a lot, we have collected some other important tools to enhance AngularJS performance.

Check out the following list of four AngularJS performance enhancing tools.

1. Protractor

Protractor is the most powerful automated end-to-end Angular testing tool, which was developed by the Angular team. Protractor is built by combining some great technologies like NodeJS, Selenium, webDriver, Mocha, Cucumber, and Jasmine.

protractor-logo

2. GulpJS

GulpJS is used for automating repetitive tasks, the streaming build system, and linting JavaScript using JSHint or ESLint.

gulp-1

3. TestingWhiz

TestingWhiz is one of the most user-friendly test automation tools because of its codeless scripting feature. TestingWhiz offers an end-to-end testing solution to test AngularJS applications. It has a variety of test commands to easily create tests related to AngularJS. With a more dynamic wait command, TestingWhiz synchronizes with the varying server wait times for AngularJS components.

testingwhiz-version-2-0-released

WebdriverIO 

WebdriverIO lets you control a browser or a mobile application with just a few lines of code. Your test code will look simple, concise, and easy to read. The integrated test runner lets you write asynchronous commands in a synchronous way so that you don’t need to care about how to handle a promise to avoid racing conditions. Additionally, it takes away all the cumbersome setup work and manages the Selenium session for you.

webdriverio

Conclusion

As we have seen, web development is changing rapidly due to the introduction of many new and updated JavaScript frameworks. To get maximum benefits from these frameworks, you must keep optimizing performance on regular basis.

AngularJS is a powerful framework to build web applications like no other. By improving AngularJS performance, developers become able to do more with less coding. Even the risk of producing “spaghetti code” is greatly reduced.

Top 10 New Features Of Angular 8

 One of the most popular Javascript frameworks - Angular has finally released it’s latest Angular 8 version on 23 May 2019. The latest release of Google’s Angular framework has bought several attractive features that made Angular 8 unique compared to its previous versions. In this blog, we will discuss the top 10 Angular 8 features & updates.

History of previous angular’s versions

If you previously know the history of Angular versions & features, or if you only want to focus on Angular 8, please skip this part and move on to the next – Angular 8 features.

Angular is one of the most popular front-end JavaScript framework comparing React & Vue.js for web app development. Its first version was released in 2009 and It has been around for the past 10 years, and since then, it brought an impressive list of changes and improvements.

The first version of the framework was launched in 2009 known by AngularJS. Though it was completely not a perfect framework back then, majorly due to its large bundle size, complicated debugging issue, dependency injection stops to work after minification of code, performance issues, and other technical problems.

The competition was tough so Google’s engineering team make many changes to their framework have added really powerful libraries and new features like AOT, tree-shaking to make it better for every AngularJS Development Company. Angular 2 was completely rewritten it's not an upgrade of version 1. It was released with Typescript which is a superset of JavaScript introduced by Microsoft and chosen by the Angular team for development. Typescript is a great way to write javascript. Angular 2 introduced Hierarchical Dependency Injection system as everything is a class in Angular, so DI is achieved via a constructor. The compiler was updated and used to optimize the production of template-rendering, which help the code to execute at the maximum speed in JVMs.

The main reason behind skipping version 3 was to avoid confusion as the core Angular libraries was live on one single GitHub repository at @angular/angular with versioned the same way but distributed as different NPM packages causing misalignment of the router package’s version that was already distributed as version 3.3.0 so team decided to skip version 3 and move ahead with Angular v4 which aligned all the core packages and help avoid confusion in the future.

With view-engine enhancements and code generation reductions in Angular 4, applications consumed less memory and they run quicker than their previous versions. Angular Universal was introduced as the core Angular Module which makes it easy to import the functions from the library.

Angular team has introduced progressive web apps support to their Angular version 5 to get the features of native mobile applications with the mobile web apps along with improvements & enhancements in Material Design & added build optimizer that makes the application lighter and faster by removing the unnecessary run-time code.

The main updates in Angular 6 were ng update, Bazel Compiler, Service Worker Support, Angular elements, CLI Workspaces, Animations Performance Improvements, ng add, and Angular Material + CDK components.

The Angular 7 version is primarily focused on the Ivy project but they have not introduced ivy in their angular 7 and talking about other major changes like new CLI, ScrollingModule, DragDropModule, major performance tweak by removing reflect-metadata polyfill which automatically included in the production and by adding Budget Bundles by default which will notify you when your app is reaching size limits. Angular 7 updated to typescript 3.1, RxjS 6.3 and added Node 10 support.

Features & Updates of Angular 8

Angular 8 New Features

Angular 8 has arrived and with it a bunch of workflow and a new set of powerful features that Angular developers will appreciate like the core framework, Angular Material library, and the Command Line Interface. They have enabled major launch partner as Angular Console for running Angular projects, #angular/fire for integrating Firebase with Angular, StackBlitz integrated IDE and NativeScript for building native mobile apps with Angular. let’s go over and summarize what are new features introduced in Angular 8 as well as how upgrading your Angular 7 apps to Angular 8.

Preview of Ivy

If you have been following Angular then you probably encountered the word “Ivy”. Ivy is a major change in Angular history, it an angular renderer which is radically different from anything as it uses incremental DOM. It changes how the framework internally works, without changing our Angular applications. The Ivy project is basically rewriting the Angular compiler and runtime code in order to reach

  • better build times ( incremental approach)
  • better build sizes more compatible with tree-shaking
  • new potential features like lazy loading of component instead of modules

Angular Ivy works 

The key idea behind Incremental DOM is every component gets compiled into a series of instructions. These instructions create DOM trees and update them in-place when the data changes.

@Component({
selector: 'todos-cmp',
template: `
<div *ngFor="let t of todos|async">
{{t.description}}
</div>
`
})
class TodosComponent {
todos: Observable<Todo[]> = this.store.pipe(select('todos'));
constructor(private store: Store<AppState>) {}
}

Will be compiled into:

var TodosComponent = /** @class */ (function () {
function TodosComponent(store) {
this.store = store;
this.todos = this.store.pipe(select('todos'));
}
TodosComponent.ngComponentDef = defineComponent({
type: TodosComponent,
selectors: [["todos-cmp"]],
factory: function TodosComponent_Factory(t) {
return new (t || TodosComponent)(directiveInject(Store));
},
consts: 2,
vars: 3,
template: function TodosComponent_Template(rf, ctx) {
if (rf & 1) { /** create dom*/
pipe(1, "async");
template(0, TodosComponent_div_Template_0, 2, 1, null, _c0);
} if (rf & 2) { /** create dom*/
elementProperty(0, "ngForOf", bind(pipeBind1(1, 1, ctx.todos)));
}
},
encapsulation: 2
});

return TodosComponent;
}());

The template function contains the instructions rendering and updating the DOM as they are rendering engine.

Two main concepts of IVY

  • Tree shakable: It means removing unused pieces of your code, the framework does not interpret the component. Instead, the component references instructions. If it doesn’t reference a particular instruction, which will never be used so we can omit the unused instruction from the bundle results in smaller bundles and faster load times.

tree shaking

  • Low Memory Footprint: Incremental DOM doesn’t need any memory to rerender the view if it doesn’t change the DOM so it allocates the memory when the DOM nodes are added or removed. since most of render/template calls don’t change anything result in huge memory savings.

Low_Memory_Footprint

Differential Loading

Angular 8 apps will now be more performant, thanks to Differential Loading of Modern JavaScript. With differential loading, new apps generated by Angular CLI will now contain separate bundles for legacy JavaScript (ES5) and modern JavaScript (ES2015+).

Differential Loading of Modern JavaScript

The correct bundle will be loaded automatically by the browser & will be able to download smaller, more efficient app bundles that load and render faster.

Angular Router Backwards Compatibility

Angular 8 feature added backward compatibility mode to Angular router that helps to upgrade the path for large projects and will make it easier to move to Angular by allowing lazy loading parts of Angular v1.x apps using $route APIs.In simple word, we will be able to upgrade our Angular 1.x apps to Angular 2+ right away.

Improved Web Worker Bundling

Thanks to Angular CLI 8, web workers are included while building the production bundles which are essential for improving the parallelizability and helps increase the performance. Angular 8.0 is thus adding building support to CLI which provides one bundle for every web worker.

ng g webWorker <name>

Bazel Support

One of the new features of Angular 8 is the possibility to build your CLI application with Bazel. The Angular framework itself is built with Bazel.
It is available as opt-in, it is expected to be included in @angular/cli in Version 9.

bazel_complier


Bazel key advantages are:

  • We will be able to build our backends and frontends with the same tool
  • Faster build time The first build will be painfully slow, as Bazel is aiming for exactly reproducible builds but concurrent builds will be a lot faster & it will be beneficial if your app uses several modules and libraries.
  • Incremental Build: Codebase will only trigger the smallest rebuild possible help to build and deploy only what has changed rather than the entire App.
  • You can eject the Bazel files, they are hidden by default.
  • The possibility to have remote builds (with cache) on a build farm

Lazy Loading

Lazy loading is based on the concepts of Angular Routing as it helps bring down the size of large files by lazily loading the files that are required. In previous angular versions, the route configuration uses the property @loadChildren which accepts a string and if there was a wrong module name or any typo while writing the code, Angular would not consider it wrong and accept whatever value was there as a string until we try building it.

So to overcome that they have added support for dynamic imports in router configuration in latest Angular 8 which enable the use of import statement for lazy loading the module and this will be understood by the IDEs, webpack etc.

lazy-loading

Now Editor will understand what's this syntax and will recognize if there is some mistake and we won't have to wait till build time to realize about an error.

lazy-loading

To keep their efforts in alignment with the community’s needs Angular CLI will be gaining another new feature i,e opt-in usage sharing. This feature will enable opt-in to sharing telemetry about your Angular CLI usage with the Angular team and now Angular 8 can collect data like commands used and the build speed if users allow them which will help developers improve in future.

contact us

CLI workflow improvements

The Angular CLI is continuously improving, and now the ng-build, ng-test and ng-run are equipped to be extended by 3rd-party libraries and tool.
For Example: AngularFire

Builders API

The new version allows us to use Builders API. It uses builders for main operations like: serve, build, test, lint and e2e. Basically, the builder Builders are functions that implement the logic and behavior for a task that can replace a command which you pass to the createBuilder() method from @angular-devkit/architect package & now we can create our custom builders as well.

import { BuilderOutput, createBuilder } from '@angular-devkit/architect';
export default createBuilder((options, context) => {
return new Promise<BuilderOutput>(resolve => {
resolve({ success: true });
});
});

AngularJS API Migration Improvements with $location service

The Angular Team wants to provide support for all developers using AngularJS to upgrade them with latest Angular so some enhancements have been made to provide better integration with the AngularJS $location service in hybrid (AngularJS <=> Angular) apps. A new package angular/common/upgrade is added help you

  • To retrieve the state from location service.
  • To track all location changes.
  • Help you retrieve hostname protocol port search properties which were available in AngularJS.
  • MockPlatformLocation API added to test the location service.

Service Worker

Angular ships with a service worker implementation Starting with version 5. With the Angular Service Worker and the Angular CLI built-in PWA support angular developers can take advantage of this service worker and benefit from the increased reliability and performance it provides, without needing to code against low-level APIs and can achieve native-like application download and Installation.

Updated Typescript to 3.4.x

In the newest version of Angular 8, they have updated Angular’s dependencies which include tools like RxJS and TypeScript to v3.4 ( Angular 7 uses v3.2) and new apps generated via the Angular CLI will also use the newest version of TypeScript by default.

Angular Firebase

Angular have officially added support for firebase and now we can deploy our application using the Angular CLI.

ng run [PROJECT_NAME]:deploy

Deprecated APIs and Features

Angular aims to balance innovation and stability in their framework and to do that they have removed or replaced some features & API'S so that Angular can stay updated with latest practices, changing dependencies, or changes in the platform itself.

To make these transitions easy they deprecate APIs and features for a period of time before removing them which provides developers time to update your apps to the latest APIs and best practices.

  • Web Tracing Framework integration
  • @angular/platform-webworker and@angular/platform-webworker-dynamic both the packages are deprecated
  • Usage for any in TesBed.get
  • Removed deprecated DOCUMENT from @angular/platform-browser
  • @angular/http removed from the list of packages
  • ngForm element selector
  • Service worker versionedFiles

Angular Performance & Upgradation from Angular 7 to Angular 8

Angular 8 new features are nice, but the main reason for many of us to upgrade to new versions of Angular 8 is to get a performance boost. If you worked with previous angular versions then upgrading an app from Angular 7 over to Angular 8 is simple.

For most developers, one command should take care of this update :

ng update @angular/cli @angular/core <name>>

Final Thoughts on Angular 8

Summing up all the above features, The Angular team has certainly did a great with the framework making developers job much easier & simpler. Angular version 8 looks like a much more accessible solution focused on the modern technological trends added features like Ivy, route configurations use dynamic Imports, new builder API in the CLI, web worker support, Unified Angular Location Service & with every new release, the framework is getting smoother and smoother making the Angular platform better.

Technology’s generational moment with generative AI: A CIO and CTO guide

 Ref:  A CIO and CTO technology guide to generative AI | McKinsey 1. Determine the company’s posture for the adoption of generative AI As us...