• Technologies
  • AI Tips and Tricks
  • Frontend
  • Backend
  • Server
  • Contact
  • About
Wednesday, June 4, 2025
Adnan Halilovic Blog
  • Technologies
    • All
    • Angular
    • Git
    • JavaScript
    • ReactJS
    VS Code Setup for Angular Developers Featured Image

    Best VS Code Setup for Angular Development

    Mastering DevTools: Supercharge Your Workflow with Code Snippets!

    Mastering DevTools: Supercharge Your Workflow with Code Snippets!

    Quokka.js and Wallaby.js Giveaway

    Quokka.js and Wallaby.js Giveaway

    How to Work on Different Git Branches at the Same Time?

    How to Work on Different Git Branches at the Same Time?

    Lazyload Standalone Components in Angular

    Lazyloading Standalone Components in Angular

    Standalone Components Angular

    How to Create Standalone Components in Angular

    Private Routes in React Router V6

    Protecting Routes in React JS

    How to setup routing in ReactJS

    How to setup routing in ReactJS

    Retry Error HTTP Requests in Angular (without retryWhen)

    Retry Error HTTP Requests in Angular (without retryWhen)

  • AI Tips and Tricks
  • Frontend
  • Backend
  • Server
  • Contact
  • About
No Result
View All Result
  • Technologies
    • All
    • Angular
    • Git
    • JavaScript
    • ReactJS
    VS Code Setup for Angular Developers Featured Image

    Best VS Code Setup for Angular Development

    Mastering DevTools: Supercharge Your Workflow with Code Snippets!

    Mastering DevTools: Supercharge Your Workflow with Code Snippets!

    Quokka.js and Wallaby.js Giveaway

    Quokka.js and Wallaby.js Giveaway

    How to Work on Different Git Branches at the Same Time?

    How to Work on Different Git Branches at the Same Time?

    Lazyload Standalone Components in Angular

    Lazyloading Standalone Components in Angular

    Standalone Components Angular

    How to Create Standalone Components in Angular

    Private Routes in React Router V6

    Protecting Routes in React JS

    How to setup routing in ReactJS

    How to setup routing in ReactJS

    Retry Error HTTP Requests in Angular (without retryWhen)

    Retry Error HTTP Requests in Angular (without retryWhen)

  • AI Tips and Tricks
  • Frontend
  • Backend
  • Server
  • Contact
  • About
No Result
View All Result
Adnan Halilovic Blog
No Result
View All Result

Lazyloading Standalone Components in Angular

Adnan Halilovic by Adnan Halilovic
September 11, 2022
in Angular, Frontend, Technologies
0
0
SHARES
1.2k
VIEWS
Share on FacebookShare on Twitter
ADVERTISEMENT

Standalone components are a new feature in Angular 14, but lazyloading standalone components is something you should also use as well!


The lazy loading components feature allows us to easily ‘detach’ components from our build and serve them to our users as per their need, instead of bundling everything and sending it to the user.

How to?

This is actually easier than it sounds. The only requirement is that the lazyloaded component has to be standalone, otherwise this won’t work. So take a look at the app-routing.module.ts file:

import { NgModule } from '@angular/core';
import { Route, RouterModule, Routes } from '@angular/router';
import { DefaultComponent } from './default/default.component';

const routes: Routes = [
  { path: '', pathMatch: 'full', redirectTo: 'home' },
  { path: 'home', component: DefaultComponent },
  {
    path: 'standalone',
    loadComponent: () =>
      import('./standalone/standalone.component').then(
        (m) => m.StandaloneComponent
      ),
  },
  {
    path: 'standalone2',
    loadComponent: () =>
      import('./standalone2/standalone2.component').then(
        (m) => m.StandaloneComponent2
      ),
  },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
})
export class AppRoutingModule {}

As you could see in the code above, we have used a new key in the router object, named loadComponet`, and imported the component as per request. Using this way, we don’t have to import the components in the module itself and call them when navigating, we are doing this lazily.

If we take a look at our networks tab of the browser inspector, we would be able to see that the components are loading lazily while navigating between routes.

ADVERTISEMENT
Standalone components lazy loading in the networks tab preview.

Conclusion

Lazyloading standalone components is a simple-to-implement, yet potent feature for enhancing the performance of Angular applications.

Here is a link to the project’s GitHub page: adnan-halilovic/lazyload-standalone-components-angular: Lazyload Standalone Components in Angular – Youtube Video (github.com)

ADVERTISEMENT

Thank you for reading the article!

If you like the article and the content, you can follow me on YouTube, Instagram, Linkedin, or any other social networks that you can find listed on my page.

Source: Youtube
Tags: AngularRoutingstandalone components
ADVERTISEMENT
Previous Post

How to Create Standalone Components in Angular

Next Post

How to Work on Different Git Branches at the Same Time?

Related Posts

Windsurf SWE-1 Featured Image
AI Tips and Tricks

Windsurf SWE-1: A Groundbreaking Frontier Model Family for Engineers

May 20, 2025
AI Coding Competition Featured Image
AI Tips and Tricks

LM Arena: The Ultimate Playground for Web Developers to Benchmark AI Language Models

May 20, 2025
VS Code Setup for Angular Developers Featured Image
Angular

Best VS Code Setup for Angular Development

October 13, 2024
My Top 5 Uncommon VS Code Extensions for 2024!
Frontend

My Top 5 Uncommon VS Code Extensions for 2024!

January 27, 2024
Mastering DevTools: Supercharge Your Workflow with Code Snippets!
Frontend

Mastering DevTools: Supercharge Your Workflow with Code Snippets!

September 24, 2023
Quokka.js and Wallaby.js Giveaway
Frontend

Quokka.js and Wallaby.js Giveaway

July 26, 2023
Next Post
How to Work on Different Git Branches at the Same Time?

How to Work on Different Git Branches at the Same Time?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Latest posts

Windsurf SWE-1 Featured Image
AI Tips and Tricks

Windsurf SWE-1: A Groundbreaking Frontier Model Family for Engineers

by Adnan Halilovic
May 20, 2025
0

Windsurf has just announced something that’s sending waves through the tech and software development community: the release of their first-ever Frontier...

Read moreDetails
AI Coding Competition Featured Image

LM Arena: The Ultimate Playground for Web Developers to Benchmark AI Language Models

May 20, 2025
TRAE: A Free AI-Powered Code Editor Built by TikTok’s Parent Company

TRAE: A Free AI-Powered Code Editor Built by TikTok’s Parent Company

May 20, 2025
The One MCP Server Every Developer Should Be Using

The One MCP Server Every Developer Should Be Using

May 13, 2025
Boosting Productivity with AI-Powered IDEs: My Workflow with Windinsurf

Boosting Productivity with AI-Powered IDEs: My Workflow with Windinsurf

May 12, 2025
Github LinkedIn Youtube Twitter Pinterest Instagram Reddit

About Me

Adnan Halilovic Blog

Adnan Halilović

Software Developer - Content Writer

I am Adnan Halilović, the man behind the website and channels that you are currently reading and viewing!

I am a software developer with over 15 years of expertise in a variety of fields.

Newsletter

Country:

Email address:


Recent from Instagram

    The Instagram Access Token is expired, Go to the Customizer > JNews : Social, Like & View > Instagram Feed Setting, to refresh it.

© 2022 Adnan Halilovic - Software development content, tips & tricks.

Click to Copy
No Result
View All Result
  • Technologies
  • AI Tips and Tricks
  • Frontend
  • Backend
  • Server
  • Contact
  • About

© 2022 Adnan Halilovic - Software development content, tips & tricks.