All Projects → juristr → ngx-lazy-el

juristr / ngx-lazy-el

Licence: MIT license
Lazy Loading Angular Components made easy powered by Angular Elements

Programming Languages

typescript
32286 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
shell
77523 projects

Projects that are alternatives of or similar to ngx-lazy-el

lazy-load
🌅 Lazy Loading module for Nuxt 3
Stars: ✭ 30 (+15.38%)
Mutual labels:  lazy-loading
bs-dynamic-import
📦🚀 BuckleScript dynamic import interop on JavaScript environment
Stars: ✭ 31 (+19.23%)
Mutual labels:  lazy-loading
react-cool-virtual
😎 ♻️ A tiny React hook for rendering large datasets like a breeze.
Stars: ✭ 1,031 (+3865.38%)
Mutual labels:  lazy-loading
loadeer
🦌 Tiny, performant, SEO-friendly lazy loading library
Stars: ✭ 30 (+15.38%)
Mutual labels:  lazy-loading
lazysimon
Minimal effort 350 byte JavaScript library to lazy load all <img> on your website
Stars: ✭ 18 (-30.77%)
Mutual labels:  lazy-loading
ember-cli-g-maps
Deprecated Google Maps Addon
Stars: ✭ 58 (+123.08%)
Mutual labels:  lazy-loading
angular-image-loader
A simple progressive, responsive, lazy image and video loading library for Angular that detects browser size and loads the appropriate image or video only when the element is in viewport. This package requires @thisissoon/angular-inviewport
Stars: ✭ 21 (-19.23%)
Mutual labels:  lazy-loading
skeleton-carousel
Carousel component. Horizontal and vertical swipe navigation
Stars: ✭ 31 (+19.23%)
Mutual labels:  lazy-loading
reason-react-lazy-loading
Example project to show how to use components lazy loading in ReasonReact
Stars: ✭ 41 (+57.69%)
Mutual labels:  lazy-loading
angular-app
Angular 14 ,Bootstrap 5, Node.js, Express.js, ESLint, CRUD, PWA, SSR, SEO, Universal, Lazy Loading
Stars: ✭ 389 (+1396.15%)
Mutual labels:  lazy-loading
angular-lazy-loading
Angular 15 & React 18 Examples Lazy Loading
Stars: ✭ 39 (+50%)
Mutual labels:  lazy-loading
example-app
Example app showcasing fulls1z3's Angular libraries
Stars: ✭ 27 (+3.85%)
Mutual labels:  lazy-loading
osprey-delight
Osprey Delight is the free-minded artist's choice for a clutter-free and blazingly fast single-page portfolio.
Stars: ✭ 43 (+65.38%)
Mutual labels:  lazy-loading
relaze
Tiny image lazy loading library for React.
Stars: ✭ 20 (-23.08%)
Mutual labels:  lazy-loading
angular-universal-localize-router
Angular (5-14) + universal + ngx-translate + localize-router + lazyloading
Stars: ✭ 14 (-46.15%)
Mutual labels:  lazy-loading
GDX-lazy-font
auto self-generate BitmapFont for libgdx 1.5.0 +
Stars: ✭ 26 (+0%)
Mutual labels:  lazy-loading
disqus-conditional-load
Advanced plugin for Disqus WordPress
Stars: ✭ 21 (-19.23%)
Mutual labels:  lazy-loading
nuxt-speedkit
nuxt-speedkit will help you to improve the lighthouse performance score (100/100) of your website.
Stars: ✭ 401 (+1442.31%)
Mutual labels:  lazy-loading
TIFFStack
Load TIFF files into matlab fast, with lazy loading
Stars: ✭ 32 (+23.08%)
Mutual labels:  lazy-loading
esri-react-router-example
Example of how to load and use the ArcGIS API for JavaScript in a react-router application
Stars: ✭ 24 (-7.69%)
Mutual labels:  lazy-loading

ngx-lazy-el

npm version

Easy lazy loading components 💪 by Angular Elements.

How to use it

Also check out my talks about using this library

Install Angular Elements on your project

This library depends on Angular Elements. You can install that via

$ ng add @angular/elements

Install ngx-lazy-el

Install the library from npm.

$ npm install @juristr/ngx-lazy-el

or

$ yarn add @juristr/ngx-lazy-el

Lazy load a component

1) Configure the Module containing the lazy loaded component

First of all, expose the Angular Component that should be loaded via a customElementComponent property.

...
@NgModule({
  declarations: [HelloWorldComponent],
  ...
  exports: [HelloWorldComponent]
})
export class HelloWorldModule {
  customElementComponent: Type<any> = HelloWorldComponent;
}

2) Define the lazy component map in your AppModule

Just like with the Angular Router, define the map of component selector and lazy module.

// app.module.ts
...
const lazyConfig = [
  {
    selector: 'app-hello-world',
    loadChildren: () =>
      import('./hello-world/hello-world.module').then(m => m.HelloWorldModule)
  }
];

@NgModule({
  ...
  imports: [
    ...
    NgxLazyElModule.forRoot(lazyConfig),
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {}

3) Use the lazy loaded Component

To use the lazy loaded component in another module, first of all register the CUSTOM_ELEMENT_SCHEMA.

import { ..., CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

@NgModule({
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  imports: [NgxLazyElModule]
  ...
})
export class SomeModule {}

That is needed because otherwise Angular won't recognize the tag as it is no more an Angular Component, but Custom Element. Also note that I import the NgxLazyElModule if you haven't already. Otherwise the *ngxLazyEl directive won't work.

Now you can just use the Custom Element by applying the *ngxLazyEl directive.

<app-hello-world *ngxLazyEl [person]="person"></app-hello-world>

If it is behind a *ngIf or other non-visible component, the app-hello-world will be lazy loaded on the fly.

Questions?

Open an issue or ping me on Twitter.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].