Provides methods for lazy loading scripts and styles programatically.
The service keeps track of loaded files to skip reloading unless specified otherwise in the options of loadScript()
or loadStyle()
.
async/src/lazy-loader/lazy-loader.service.ts
Methods |
|
constructor(head: HeadService, universal: UniversalService)
|
|||||||||
Parameters:
|
|||||||||
Public isCached | ||||||||
isCached(url: string)
|
||||||||
Checks whether the file from the specified url has already been cached.
Parameters:
Returns:
boolean
A value indicating whether the file from the specified url has already been cached. |
||||||||
Public isScriptPresent | ||||||||
isScriptPresent(url: string)
|
||||||||
Checks whether a script element is already present in
Parameters:
Returns:
boolean
|
||||||||
Public isStylePresent | ||||||||
isStylePresent(url: string)
|
||||||||
Checks whether a link element is already present in
Parameters:
Returns:
boolean
|
||||||||
Public loadScript | |||||||||||||||
loadScript(url: string, options: ScriptLoadOptions)
|
|||||||||||||||
Loads a script programatically.
Parameters:
Returns:
Observable<LazyLoadedFile | null>
An observable object which allows subscribers to know when the script has been loaded and access its associated |
|||||||||||||||
Public loadStyle | |||||||||||||||
loadStyle(url: string, options: LoadOptions)
|
|||||||||||||||
Loads a style programatically.
Parameters:
Returns:
Observable<LazyLoadedFile | null>
An observable object which allows subscribers to know when the style has been loaded and access its associated |
|||||||||||||||