Socket
Book a DemoInstallSign in
Socket

@ng-util/lazy

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ng-util/lazy

Lazy load javascript, css resources for Angular.

20.1.0
latest
Source
npmnpm
Version published
Weekly downloads
2.5K
7.11%
Maintainers
1
Weekly downloads
 
Created
Source

@ng-util/lazy

Lazy load javascript, css resources for Angular.

NPM version Build Status codecov Dependency Status prettier GitHub license

Demo

Usage

import { Component } from '@angular/core';
import { NuLazyService } from '@ng-util/lazy';

@Component({
  selector: 'app-demo',
  template: ` <button *ngIf="loaded" type="button" class="btn btn-primary">Primary</button>`,
})
export class DemoComponent {
  private srv = inject(NuLazyService);
  loaded = false;

  constructor() {
    this.load();
  }

  async load() {
    await this.srv.load([
      `https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css`,
      `https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.4.1/js/bootstrap.bundle.min.js`,
    ]);
    this.loaded = true;
  }
}

API

nametypedescription
monitor(paths: string | Array<string | NuLazyResources>)Observable<NuLazyResult[]>Monitor for the finished of paths
clear()voidClean all cached items
load(paths: string | Array<string | NuLazyResources>)Promise<NuLazyResult[]>Load the specified resources, includes .js, .css
loadScript(path: string, options?: { innerContent?: string })Promise<NuLazyResult>Load a script resources
loadStyle(path: string, options?: { ref?: string, innerContent?: string })Promise<NuLazyResult>Load a style resources

License

The MIT License (see the LICENSE file for the full text)

Keywords

angular

FAQs

Package last updated on 04 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.