Lazy load resources for Angular
import { LazyService } from 'nu-lazy';
export class AppComponent {
constructor(private srv: LazyService) { }
async loadBS() {
const res = await this.srv.load(`https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css`);
console.log(`bootstrap`, res);
}
Stackblitz
sample available here.
name | type | description |
---|---|---|
events |
Observable<LazyResult[]> |
Events change callback |
clear() |
void |
Clean all cached items |
load(paths: string | string[]) |
Promise<LazyResult[]> |
Load the specified resources, includes .js , .css |
loadScript(path: string) |
Promise<LazyResult> |
Load a script resources |
loadStyle(path: string) |
Promise<LazyResult> |
Load a style resources |
nu-lazy is released under the MIT license.